-
Notifications
You must be signed in to change notification settings - Fork 3
/
db.py
31 lines (27 loc) · 894 Bytes
/
db.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
from pydal import DAL, Field
from datetime import datetime
db = DAL('sqlite://download.db')
market = db.define_table(
'market',
Field('name'),
Field('ask', type='double'),
Field('timestamp', type='datetime', default=datetime.now)
)
db.executesql('CREATE INDEX IF NOT EXISTS tidx ON market (timestamp);')
db.executesql('CREATE INDEX IF NOT EXISTS m_n_idx ON market (name);')
buy = db.define_table(
'buy',
Field('market'),
Field('purchase_price', type='double'),
Field('selling_price', type='double'),
Field('amount', type='double'),
)
db.executesql('CREATE INDEX IF NOT EXISTS sidx ON buy (selling_price);')
picks = db.define_table(
'picks',
Field('market'),
Field('old_price', type='double'),
Field('new_price', type='double'),
Field('gain', type='double'),
Field('timestamp', type='datetime', default=datetime.now)
)