Added check if database is not created.
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
from os import path
|
||||||
import aiosqlite
|
import aiosqlite
|
||||||
|
|
||||||
from .create import create_tables_if_not_exists
|
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_PATH = 'res/db/'
|
||||||
DB_FILENAME = 'database.db'
|
DB_FILENAME = 'database.db'
|
||||||
|
|
||||||
|
if not path.exists('res/db/database.db'):
|
||||||
create_tables_if_not_exists(f'{DB_PATH}{DB_FILENAME}')
|
create_tables_if_not_exists(f'{DB_PATH}{DB_FILENAME}')
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ Create database file and tables if not exists.
|
|||||||
*(text, not null)*.
|
*(text, not null)*.
|
||||||
"""
|
"""
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
import logging
|
||||||
|
|
||||||
|
|
||||||
CREATE_SERVICES_TABLE = '''CREATE TABLE IF NOT EXISTS services (
|
CREATE_SERVICES_TABLE = '''CREATE TABLE IF NOT EXISTS services (
|
||||||
@@ -75,3 +76,4 @@ def create_tables_if_not_exists(dbfile: str) -> None:
|
|||||||
connection.commit()
|
connection.commit()
|
||||||
cursor.close()
|
cursor.close()
|
||||||
connection.close()
|
connection.close()
|
||||||
|
logging.warning('Database created!')
|
||||||
Reference in New Issue
Block a user