-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_database.py
More file actions
37 lines (25 loc) · 830 Bytes
/
Copy pathcreate_database.py
File metadata and controls
37 lines (25 loc) · 830 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
36
37
import sys
import sqlite3
import configparser
def create_database(db_name:str = "database") -> None:
file = open(config['DATABASE']['DDL'], encoding='utf-8')
query_create = file.read()
cursor.executescript(query_create)
connection.commit()
def insert_system_information() -> None:
values = ("database version",config['SYSTEM']['VERSION'])
query = f""" INSERT INTO system (id, key, value)
VALUES(1, ?, ?)
;
"""
cursor.execute(query,(values))
connection.commit()
if __name__ == '__main__':
config = configparser.ConfigParser()
config.read('config.ini')
connection = sqlite3.connect(config['DATABASE']['FILE'])
cursor = connection.cursor()
create_database()
insert_system_information()
cursor.close()
connection.close()