FIX migrate function.

pull/3/head
kevin caires 3 years ago
parent 2a810d423b
commit 95806b80e2

@ -6,7 +6,7 @@ from argparse import ArgumentParser
from settings.config import DISCORD_BOT_TOKEN
from utils.commands import client
from utils.database import DataBase
from utils.database import migrate
logger = logging.getLogger(__name__)
@ -26,4 +26,4 @@ if command.command == 'run':
except Exception as ex:
logger.error(ex.args[0])
elif command.command == 'migrate':
DataBase.migrate()
migrate()

@ -36,24 +36,20 @@ class Cursor:
self.conn.close()
class DataBase:
def migrate() -> None:
"""
Database handler.
Create tables.
"""
@staticmethod
def migrate() -> None:
"""
Create tables.
"""
_sql = '''
create table if not exists neeble_quotes(
id int auto_increment primary key,
user varchar(200) not null,
quote text not null unique
);
'''
try:
with Cursor(MYSQL_CONFIG) as cursor:
cursor.execute(_sql)
except Exception as ex:
logger.error(ex.args)
_sql = '''
create table if not exists neeble_quotes(
id int auto_increment primary key,
user varchar(200) not null,
quote varchar(500) not null unique,
index quote_idx (quote)
);
'''
try:
with Cursor(MYSQL_CONFIG) as cursor:
cursor.execute(_sql)
except Exception as ex:
logger.error(ex.args)

Loading…
Cancel
Save