-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.py
37 lines (29 loc) · 1.01 KB
/
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
32
33
34
35
36
37
import sqlalchemy
from datetime import datetime
from sqlalchemy import create_engine, Column, Integer,String,DateTime
from sqlalchemy.ext import declarative
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class Image(Base):
__tablename__ ='images'
id = Column(Integer, primary_key=True)
filename = Column(String)
extension = Column(String)
filepath = Column(String)
uploader = Column(String,default='admin')
created_on = Column(DateTime, default=datetime.now)
def __str__(self):
return self.filename
class Video(Base):
__tablename__ ='videos'
id = Column(Integer, primary_key=True)
filename = Column(String)
extension = Column(String)
filepath = Column(String)
uploader = Column(String,default='admin')
created_on = Column(DateTime, default=datetime.now)
def __str__(self):
return self.filename
if __name__ == "__main__":
engine = create_engine('sqlite:///db.sqlite3')
Base.metadata.create_all(engine)