-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata.py
49 lines (37 loc) · 1.36 KB
/
data.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
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String
from sqlalchemy import create_engine, ForeignKey
from sqlalchemy.orm import sessionmaker, relationship, backref
import config
engine = create_engine('sqlite:///database/domains.db', echo=False)
Session = sessionmaker(bind=engine)
db = Session()
Base = declarative_base()
class Domain(Base):
__tablename__ = "domains"
id = Column(Integer, primary_key=True)
status = Column(String)
createTimestamp = Column(String)
updateTimestamp = Column(String)
name = Column(String)
record = Column(String)
blocks = Column(String)
rand1 = Column(String)
rand2 = Column(String)
confirmation = Column(String)
def __init__(self, status, createTimestamp, updateTimestamp, name, record, blocks, rand1, rand2, confirmation):
self.status = status
self.createTimestamp = createTimestamp
self.updateTimestamp = updateTimestamp
self.name = name
self.record = record
self.blocks = blocks
self.rand1 = rand1
self.rand2 = rand2
self.confirmation = confirmation
def reset():
Base.metadata.create_all(engine)
timestamp = config.createTimestamp()
domain = Domain('active', timestamp, timestamp, 'domain1', 'RESERVED', 10, 'xxx', 'xxx', 'xxx')
db.add(domain)
db.commit()