test impot sqdb
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Pavel_Duron 2022-12-02 18:31:37 +10:00
parent 50b7131b51
commit 73bf3af7a4
2 changed files with 17 additions and 9 deletions

9
bot.py
View File

@ -8,7 +8,7 @@ from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker from sqlalchemy.orm import sessionmaker
from aiogram import Bot, Dispatcher, executor, types from aiogram import Bot, Dispatcher, executor, types
from aiogram.types import ReplyKeyboardRemove, ReplyKeyboardMarkup, KeyboardButton 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"]) @dp.message_handler(commands=["topdick"])
async def send_time(message: types.Message): async def send_time(message: types.Message):
engine = create_engine('postgresql+psycopg2://postgres:postgres@postgres.vdk2ch.ru:5432/jack_bot', echo=True) # engine = create_engine('postgresql+psycopg2://postgres:postgres@postgres.vdk2ch.ru:5432/jack_bot', echo=True)
Session = sessionmaker(bind=engine) # Session = sessionmaker(bind=engine)
session = Session() # session = Session()
Base = declarative_base()
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() 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 = ': ' delimiter = ': '

15
sqdb.py
View File

@ -24,9 +24,18 @@ class user(Base):
datetimes = (Column(DateTime)) datetimes = (Column(DateTime))
chat_id = Column(BIGINT) chat_id = Column(BIGINT)
session.close() def __init__(self, user_id, user_fullname, dick_size, datetimes, chat_id):
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() self.user_id = user_id
print(top) 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)
#Base.metadata.create_all(engine) #Base.metadata.create_all(engine)