FIX migrate function.

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

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

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

Loading…
Cancel
Save