-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathone_time_setup.py
More file actions
35 lines (29 loc) · 970 Bytes
/
Copy pathone_time_setup.py
File metadata and controls
35 lines (29 loc) · 970 Bytes
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
import sqlite3
import flask_utilities
def get_sql_create_master_table():
return """
CREATE TABLE master_node (
filename VARCHAR(100) PRIMARY KEY NOT NULL,
primary_node VARCHAR(100) NOT NULL
);
"""
def get_sql_create_replication_table():
return f"""
CREATE TABLE replication_data (
filename VARCHAR(100) NOT NULL,
replicated_node VARCHAR(100) NOT NULL,
PRIMARY KEY (filename, replicated_node)
);
"""
def main():
db_name = flask_utilities.get_db_name()
conn = sqlite3.connect(db_name)
print(f"Created database {db_name}.")
conn.execute(get_sql_create_master_table())
print("Table created for master node.")
conn.execute(get_sql_create_replication_table())
print("Table created for storing replication data.")
conn.close()
print("Setup done!")
if __name__ == "__main__":
main()