-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
30 lines (23 loc) · 954 Bytes
/
models.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
from sqlalchemy import *
from sqlalchemy import Table, Column, DateTime, Integer, String, MetaData
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker, scoped_session
engine = create_engine('sqlite:///windowlog.db', echo=True)
Base = declarative_base(bind=engine)
Session = scoped_session(sessionmaker(engine))
class Windowlog(Base) :
__tablename__ = 'windowlog'
moment = Column(DateTime, primary_key=True)
windowname = Column(String)
pid = Column(String)
bin = Column(String)
screenshot = Column(LargeBinary)
def __init__(self, moment, windowname, pid, bin, screenshot) :
self.moment = moment
self.windowname = windowname
self.pid = pid
self.bin = bin
self.screenshot = screenshot
def __repr__(self) :
return "<Windowlog('%s', '%s', '%s', '%s')>" % (self.moment, self.windowname, self.pid, self.bin)
Base.metadata.create_all()