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

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 Column, DateTime, ForeignKey, Numeric
from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker from sqlalchemy.orm import sessionmaker
@ -23,10 +23,19 @@ class user(Base):
dick_size = (Column(Integer)) dick_size = (Column(Integer))
datetimes = (Column(DateTime)) datetimes = (Column(DateTime))
chat_id = Column(BIGINT) 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() # 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() # 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) # print(top)
#Base.metadata.create_all(engine) #Base.metadata.create_all(engine)