-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.py
More file actions
executable file
·48 lines (37 loc) · 1.21 KB
/
database.py
File metadata and controls
executable file
·48 lines (37 loc) · 1.21 KB
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
#!/usr/bin/python3
from sqlalchemy import Column, Integer, String
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class EncodedVideo(Base):
__tablename__ = 'encoded_video'
id = Column(Integer, primary_key=True)
name = Column(String(256), nullable=False)
path = Column(String(256), nullable=False)
key = Column(String(32), nullable=False)
kid = Column(String(32), nullable=False)
@property
def serialize(self):
# Return object data in serializeable format
return {
'id': self.id,
'name': self.name,
'path': self.path,
'key': self.key,
'kid': self.kid,
}
class UploadedVideo(Base):
__tablename__ = 'uploaded_video'
id = Column(Integer, primary_key=True)
name = Column(String(256), nullable=False)
path = Column(String(256), nullable=False)
@property
def serialize(self):
# Return object data in serializeable format
return {
'id': self.id,
'name': self.name,
'path': self.path,
}
engine = create_engine('sqlite:///videos.db')
Base.metadata.create_all(engine)