Example #1
0
from CURD import Database, Model, Field, PrimaryKey, ForeignKey, Sugar


class User(Model):
    name = Field()
    email = Field()


class Post(Model):
    name = Field()
    post_id = PrimaryKey()
    user_id = ForeignKey(User.id)


Database.config(db="mydb", user="******", passwd="")

User.create(name="John", email="*****@*****.**")  # create

User.at(2).update(email="*****@*****.**")  # update

John = User.where(name="John").select().fetchone()  # read

# who wrote posts?
for post, user in (Post & User).select().fetchall():
    print "Author: %s, PostName: %s" % (user.name, post.name)

User.at(3).delete()  # delete

# sytactic sugar
user = User[1]  # 1st user
users = User[:]  # all users
Example #2
0
# -*- encoding: utf-8 -*-

from CURD import Database, Model, Field, PrimaryKey, ForeignKey, Fn

Database.config(host='localhost', db='videos', user='******', passwd='1q2w3e')


class Validate(Model):
	"""
	短信验证码
	"""
	mobile = Field()
	code = Field()
	device = Field()
	valid_time = Field()
	create_date = Field()


class User(Model):
	"""
	用户信息
	"""
	id = PrimaryKey()
	mobile = Field()
	login = Field()
	password = Field()
	email = Field()
	name = Field()


class Session(Model):
Example #3
0
# coding=utf8


from CURD import Database, Model, Field, PrimaryKey
from messageboard import app


class Message(Model):
    title = Field()
    content = Field()
    create_at = Field()


Database.config(**app.config['DB_CONN_CFG'])
Example #4
0
# coding=utf8

from CURD import Database, Model, Field


Database.config(user='******', passwd='', db='mytest')


class User(Model):
    name = Field()
    email = Field()


user = User(name='Join', email='*****@*****.**')
user.save()
Example #5
0
# -*- encoding: utf-8 -*-

from CURD import Database, Model, Field, PrimaryKey, ForeignKey, Fn

Database.config(host='localhost', db='videos', user='******', passwd='1q2w3e')


class Validate(Model):
    """
	短信验证码
	"""
    mobile = Field()
    code = Field()
    device = Field()
    valid_time = Field()
    create_date = Field()


class User(Model):
    """
	用户信息
	"""
    id = PrimaryKey()
    mobile = Field()
    login = Field()
    password = Field()
    email = Field()
    name = Field()


class Session(Model):
Example #6
0
from CURD import Database, Model, Field, PrimaryKey, ForeignKey, Fn


class User(Model):
    name = Field()
    email = Field()


class Post(Model):
    name = Field()
    post_id = PrimaryKey()
    user_id = ForeignKey(User.id)


Database.config(db='mydb', user='******', passwd='')