forked from Pavel_Durov/python_bot
57 lines
1.2 KiB
Python
57 lines
1.2 KiB
Python
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()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|