Browse Source

Исправил косяк с импортами

В models и main создавались разные объекты для базы, поэтому базу не
получалось инициализировать.
master
Дмитрий 3 years ago
parent
commit
aa2c1f6a3c
  1. 11
      main.py
  2. 1
      models.py

11
main.py

@ -6,10 +6,10 @@ import asyncio
from datetime import timedelta, datetime
import secrets
from sqlalchemy import create_engine
from sqlalchemy.orm import declarative_base, sessionmaker
from sqlalchemy.orm import sessionmaker
from sqlalchemy.exc import IntegrityError
from models import Allowed_user, Token, Messages_to_delete
from sqlalchemy_utils import database_exists, create_database
from models import Allowed_user, Token, Messages_to_delete, Base
logging.basicConfig(level=logging.INFO)
DELAY_TIME = int(os.getenv("GBOT_DELAY_TIME"))
@ -23,7 +23,10 @@ bot = Bot(token=API_TOKEN)
dp = Dispatcher(bot)
engine = create_engine("sqlite:///" + str(DB_PATH))
Base = declarative_base()
# if not database_exists(engine.url):
# create_database(engine.url)
Session = sessionmaker(bind=engine)
session = Session()

1
models.py

@ -3,6 +3,7 @@ from sqlalchemy import Column, Integer, String, DateTime, UniqueConstraint
from sqlalchemy.orm import declarative_base
from datetime import datetime
# from main import Base
Base = declarative_base()

Loading…
Cancel
Save