forked from Pavel_Durov/python_bot
#7 убирац
This commit is contained in:
parent
bb91a90e9e
commit
b188edd98d
@ -1,5 +1,4 @@
|
||||
from aiogram import types, Dispatcher
|
||||
#from sqlalchemy.orm.session import close_all_sessions
|
||||
from create_bot import bot, dp
|
||||
#from sqdb import user, session
|
||||
import random
|
||||
|
@ -1,9 +1,6 @@
|
||||
|
||||
from create_bot import dp, bot
|
||||
from aiogram import types, Dispatcher
|
||||
from sqdb import user, session
|
||||
|
||||
|
||||
|
||||
@dp.message_handler(commands=['sendall'])
|
||||
async def sendall(message: types.Message):
|
||||
@ -20,9 +17,7 @@ async def sendall(message: types.Message):
|
||||
print('вероятно бота нет в чате')
|
||||
await bot.send_message(message.from_user.id, 'Сообщение успешно отправлено во все чаты')
|
||||
except:
|
||||
session.rollback()
|
||||
print('eror sendall')
|
||||
finally: session.close_all()
|
||||
|
||||
|
||||
# def register_handlers_test(dp: Dispatcher):
|
||||
|
56
sqdb.py
56
sqdb.py
@ -1,56 +0,0 @@
|
||||
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
|
||||
from sqlalchemy import select, update
|
||||
|
||||
engine = create_engine('postgresql+psycopg2://postgres:postgres@postgres.vdk2ch.ru:5432/jack_bot', echo=True)
|
||||
Session = sessionmaker(bind=engine)
|
||||
session = Session()
|
||||
|
||||
|
||||
|
||||
Base = declarative_base()
|
||||
|
||||
|
||||
|
||||
class user(Base):
|
||||
__tablename__ = 'users'
|
||||
|
||||
id = Column(Integer, primary_key=True)
|
||||
user_id = Column(Integer)
|
||||
user_fullname = Column(String)
|
||||
dick_size = (Column(Integer))
|
||||
datetimes = (Column(DateTime))
|
||||
chat_id = Column(BIGINT)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
session.close()
|
||||
engine.dispose()
|
||||
# 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)
|
||||
|
||||
# int_table = user(user_id = 12345678, user_fullname = 'test', dick_size = 10) #импортирую юзер из sqdb
|
||||
# session.add(int_table)
|
||||
# session.commit()
|
||||
# select user_id, name from employees limit 10
|
||||
|
||||
# def adding():
|
||||
|
||||
# session.add()
|
||||
# session.commit()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user