diff --git a/bot.py b/bot.py index ba74926..f215a29 100644 --- a/bot.py +++ b/bot.py @@ -8,7 +8,7 @@ from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import sessionmaker from aiogram import Bot, Dispatcher, executor, types from aiogram.types import ReplyKeyboardRemove, ReplyKeyboardMarkup, KeyboardButton -from sqdb import user +from sqdb import user, session @@ -116,10 +116,9 @@ chat_id = message.chat.id) @dp.message_handler(commands=["topdick"]) async def send_time(message: types.Message): - engine = create_engine('postgresql+psycopg2://postgres:postgres@postgres.vdk2ch.ru:5432/jack_bot', echo=True) - Session = sessionmaker(bind=engine) - session = Session() - Base = declarative_base() + # engine = create_engine('postgresql+psycopg2://postgres:postgres@postgres.vdk2ch.ru:5432/jack_bot', echo=True) + # Session = sessionmaker(bind=engine) + # session = Session() top = session.query(user.user_fullname, user.dick_size).order_by(user.dick_size.desc()).filter(user.chat_id == user.chat_id).limit(10).all() delimiter = ': ' diff --git a/sqdb.py b/sqdb.py index ba413e8..cc2e2bc 100644 --- a/sqdb.py +++ b/sqdb.py @@ -1,4 +1,4 @@ -from sqlalchemy import create_engine, MetaData, Table, Integer, String, BIGINT, \ +from sqlalchemy import create_engine, MetaData, Table, Integer, String, BIGINT, \ Column, DateTime, ForeignKey, Numeric from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import sessionmaker @@ -23,10 +23,19 @@ class user(Base): dick_size = (Column(Integer)) datetimes = (Column(DateTime)) chat_id = Column(BIGINT) + + def __init__(self, user_id, user_fullname, dick_size, datetimes, chat_id): + self.user_id = user_id + self.user_fullname = user_fullname + self.dick_size = dick_size + self.datetimes = datetimes + self.chat_id = chat_id + +print(user.chat_id) -session.close() -top = session.query(user.user_fullname, user.dick_size).order_by(user.dick_size.desc()).filter(user.chat_id == user.chat_id).limit(10).all() -print(top) +# session.close() +# top = session.query(user.user_fullname, user.dick_size).order_by(user.dick_size.desc()).filter(user.chat_id == user.chat_id).limit(10).all() +# print(top) #Base.metadata.create_all(engine)