forked from piccolo-orm/piccolo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtables.py
More file actions
43 lines (26 loc) · 862 Bytes
/
tables.py
File metadata and controls
43 lines (26 loc) · 862 Bytes
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
from piccolo.table import Table
from piccolo.columns import Varchar, ForeignKey, Integer, Numeric, Text
###############################################################################
# Simple example
class Manager(Table):
name = Varchar(length=50)
class Band(Table):
name = Varchar(length=50)
manager = ForeignKey(Manager, null=True)
popularity = Integer(default=0)
###############################################################################
# More complex
class Venue(Table):
name = Varchar(length=100)
capacity = Integer(default=0)
class Concert(Table):
band_1 = ForeignKey(Band)
band_2 = ForeignKey(Band)
venue = ForeignKey(Venue)
class Ticket(Table):
price = Numeric(digits=(5, 2))
class Poster(Table, tags=["special"]):
"""
Has tags for tests which need it.
"""
content = Text()