GithubHelp home page GithubHelp logo

bmob-py's Introduction

Bmob-Py

A Simple Bmob SDK With Python.

DEMO

from Bmob import BmobSDK, BmobModel

# define a Model
class Course(BmobModel):
	name = ''	# string
	score = 1.0	# number

# setup BmobSDK
BmobSDK.setup('77b5dad35e17a087d679e62db9936950', 'a9ab631355ce61f19be22f55a0b1b422')

# create a course and save it
c1 = Course(name="Python 2.x Program", score=4)
c1.save()

# get course of id '957638ab1e'
c2 = Course('957638ab1e')
print('%s : %s'%(c2.name, c2.score))
c2.score = c2.score+1
c2.save()

# Query:
# print the course count
print('count of courses : %d'%Course().query().count() # or Query(Course).count())

# create a Course query and query all contain "Program" courses
for c in Course().query().w_regex('name','Program').order("-createdAt").limit(20):
	print('%s  %s : %s'%(c.createdAt, c.name, c.score))

# query like a list
q = Course().query().skip(5).limit(10)
print('Items of q:')
for c in q:
	print('\t',c.objectId)
print("q.count() : %d"%q.count())
print(q[-1].name)
print(q[3:])

# delete
print('count before delete: %d'%len(Course().query()))
c1.delete()
print('count after delete: %d'%len(Course().query()))

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.