-
Notifications
You must be signed in to change notification settings - Fork 2
/
database.py
36 lines (24 loc) · 870 Bytes
/
database.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
from peewee import SqliteDatabase, Model, CharField, IntegerField, ForeignKeyField
from flask_login import UserMixin
db = SqliteDatabase('pixr.sqlite')
db.connect()
class User(UserMixin, Model):
""" Peewee model for Abstract Unit """
username = CharField(unique=True)
password = CharField()
def __str__(self): return self.username
class Meta:
database = db
class Pixels(Model):
""" Peewee model for the canvas """
user = ForeignKeyField(User)
pixel = CharField()
color = CharField()
class Meta:
database = db
def __str__(self): return self.user
if __name__ == "__main__":
db.drop_tables([User, Pixels])
db.create_tables([User, Pixels])
user = User.create(username='test', password='password')
home = User.create(username='home', password='none')