-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
45 lines (38 loc) · 1.26 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/python
# -*- coding:utf-8 -*-
import sys
sys.path.append('/home/czw/MySimpleWeb/transwarp')
import db #import create_engine, connection, execute_sql
from orm import Model, StringField, IntegerField, FloatField, DateField
class Course(Model):
cid = StringField(primary_key = True)
cname = StringField()
chours = IntegerField()
credit = FloatField()
precid = StringField()
class Student(Model):
sid = IntegerField(ddl='bigint', primary_key=True)
sname = StringField()
sex = StringField()
birthplace = StringField()
birthdate = DateField()
department = StringField()
sclass = StringField()
class Employ(Model):
sid = IntegerField(primary_key=True)
sname = StringField()
cid = StringField(primary_key=True)
cname = StringField()
garde = IntegerField()
sclass = StringField()
if __name__ == '__main__':
db.create_engine('root', 'woaini520', 'university')
with db.connection():
d={'sid':'3113000816', 'cid':'a2'}
print Employ.get(d)
#c = {'cid':'a2', 'cname':'eng', 'chours':'80', 'credit':'2.0', 'precid':'b2'}
#course1 = Course(**c)
#course1.update()
#e = {'sid':'3113000816', 'cid':'a2', 'garde':'99'}
#em1 = Employ(**e)
#em1.update()