This repository has been archived by the owner on May 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtables_definition.py
68 lines (64 loc) · 1.69 KB
/
tables_definition.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
from sqlalchemy import (
Table,
Integer,
Column,
ForeignKey,
String,
Float,
create_engine,
MetaData,
)
import json
with open("./config.json","r", encoding='utf8') as json_input:
config_api = json.load(json_input)['apiConfig']
_engine = create_engine(
config_api["databaseConnectionConfig"]["connectionString"],
connect_args={"check_same_thread": False},
)
metadata = MetaData(_engine)
c_bindings = Table(
"bindings",
metadata,
Column("id", Integer, primary_key=True, autoincrement=True, nullable=False),
Column(
"audio_id",
Integer,
ForeignKey("audio.id", onupdate="CASCADE", ondelete="RESTRICT"),
nullable=False,
),
Column(
"category_id",
Integer,
ForeignKey("categories.id", onupdate="CASCADE", ondelete="SET DEFAULT"),
nullable=False,
default=0,
),
Column(
"text_id",
Integer,
ForeignKey("texts.id", onupdate="CASCADE", ondelete="RESTRICT"),
nullable=False,
),
)
c_categories = Table(
"categories",
metadata,
Column("id", Integer, primary_key=True, nullable=False, autoincrement=True),
Column("name", String, nullable=False, unique=True)
)
c_texts = Table(
"texts",
metadata,
Column("id", Integer, primary_key=True),
Column("transcript", String, default=None),
)
c_audio = Table(
"audio",
metadata,
Column("id", Integer, primary_key=True),
Column("name", String, nullable=False),
Column("directory", String, default=None),
Column("duration_seconds", Float, nullable=False),
Column("channels", Integer, nullable=False),
Column("frame_rate", Integer, nullable=False),
)