Added check if database is not created.

This commit is contained in:
Alexey Sokolov
2022-08-11 23:31:36 +03:00
parent 8b2bcd29e5
commit e759b69b86
2 changed files with 5 additions and 2 deletions

View File

@@ -1,3 +1,4 @@
from os import path
import aiosqlite
from .create import create_tables_if_not_exists
@@ -6,5 +7,5 @@ from .create import create_tables_if_not_exists
DB_PATH = 'res/db/'
DB_FILENAME = 'database.db'
create_tables_if_not_exists(f'{DB_PATH}{DB_FILENAME}')
if not path.exists('res/db/database.db'):
create_tables_if_not_exists(f'{DB_PATH}{DB_FILENAME}')

View File

@@ -39,6 +39,7 @@ Create database file and tables if not exists.
*(text, not null)*.
"""
import sqlite3
import logging
CREATE_SERVICES_TABLE = '''CREATE TABLE IF NOT EXISTS services (
@@ -75,3 +76,4 @@ def create_tables_if_not_exists(dbfile: str) -> None:
connection.commit()
cursor.close()
connection.close()
logging.warning('Database created!')