-
Notifications
You must be signed in to change notification settings - Fork 3
/
run.py
27 lines (22 loc) · 826 Bytes
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import peewee
from src import settings
from src.logger import get_logger
from src.bot import bot
from src.database.create import create_database, create_tables
from src.logger import setup_logger
if __name__ == '__main__':
# Creates a database if it doesn't exist. This shouldn't be a problem
create_database()
try:
create_tables()
except peewee.IntegrityError:
logger = get_logger()
logger.critical(
'An error occurred while trying to securely create tables in the database. '
'Probably some of your tables are outdated, try to determine which tables are '
'causing problems and change them manually. Or call /setup.py script, '
'it will recreate the database'
)
raise
setup_logger()
bot.run(settings.TOKEN)