fixed create_schema

This commit is contained in:
nik012003
2022-06-28 13:36:17 +02:00
parent 3f2e8bb2f8
commit 631326eeb7
2 changed files with 8 additions and 11 deletions

View File

@@ -30,15 +30,10 @@ class SQLite():
def disconnect(self) -> None:
self.conn.close()
def check_integrity(self, tables = {}) -> None:
def create_schema(self, tables = {}) -> None:
cur = self.conn.cursor()
for t in tables:
cur.execute('''
SELECT name FROM sqlite_master WHERE type='table' AND name='{}';
'''.format(t))
if len(cur.fetchall()) == 0:
cur.execute('''CREATE TABLE main.{}({});'''.format(t, ''.join([(c + ' ' + tables[t][c] + ', ') for c in tables[t]])[:-2]))
cur.execute('''CREATE TABLE IF NOT EXISTS main.{}({});'''.format(t, ''.join([(c + ' ' + tables[t][c] + ', ') for c in tables[t]])[:-2]))
cur.close()
def query(self, query, *values):