-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwowdb.py
84 lines (60 loc) · 2.56 KB
/
wowdb.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db'
db = SQLAlchemy(app)
class User(db.Model):
__tablename__ = 'user'
user_name = db.Column(db.Text, primary_key = True)
login = db.Column(db.String)
server = db.Column(db.String)
class Guild(db.Model):
__tablename__ = 'guild'
user_name = db.Column(db.Text, db.ForeignKey('user.user_name')
guild = db.Column(db.String)
server = db.Column(db.String)
class User(db.Model):
__tablename__ = 'item'
user_name = db.Column(db.Text, db.ForeignKey('user.user_name')
item = db.Column(db.String)
server = db.Column(db.String)
# class Enrollment(db.Model):
# __table__ = 'enrollment'
# course_num = db.Column(db.Integer, db.ForeignKey('course.course_num'))
# student_id = db.Column(db.Integer, db.ForeignKey('student.student_id'))
#enrollment = db.Table('post_tag',
#db.Column('tag_id',db.Integer, db.ForeignKey('tag.tag_id')),
#db.Column('post_id',db.Integer, db.ForeignKey('post.post_id')),
#db.Column('tag_date',db.DateTime)
#)
#class Post(db.Model):
#__tablename__ = 'post'
#post_id = db.Column(db.Integer, primary_key=True)
#title = db.Column(db.Text)
#author = db.Column(db.Text)
#text = db.Column(db.Text)
#tags = db.relationship('Tag', secondary=post_tag,
#backref=db.backref('posts',lazy='dynamic'))
#class Tag(db.Model):
#__tablename__ = 'tag'
#tag_id = db.Column(db.Integer, primary_key=True)
#name = db.Column(db.Text)
#first_date = db.Column(db.DateTime)
#desc = db.Column(db.Text)
#db.drop_all()
#db.create_all()
#p1 = Post(post_id=1, title='first post',author='Guy Dude', text='hibbly jibbly woot de doo')
#p2 = Post(post_id=1, title='second post',author='Some Guy', text='hibbly jibbly woot de doot doo')
#db.session.add_all([p1,p2])
#t1 = Tag(tag_id=1, name='silly', first_date=datetime.datetime.now() , desc='The post is kind of silly')
##s1 = Student(student_id=1,first_name='Brad',last_name='Miller')
##s2 = Student(student_id=2,first_name='Jane',last_name='Miller')
##s3 = Student(student_id=3,first_name='Josh',last_name='Miller')
##db.session.add_all([s1,s2,s3])
##c1 = Course(course_num=150,building='Olin',room='202',students=[s1,s2])
##c2 = Course(course_num=365,building='Olin',room='202')
##db.session.add(c1)
##db.session.add(c2)
##s4 = Student(student_id=4,first_name='John',last_name='Doe',courses=[c1,c2])
##db.session.add(s4)
#db.session.commit()