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 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 = ': '

17
sqdb.py
View File

@ -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
@ -24,9 +24,18 @@ class user(Base):
datetimes = (Column(DateTime))
chat_id = Column(BIGINT)
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)
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)
#Base.metadata.create_all(engine)