python_bot_v2/sqdb.py

57 lines
1.2 KiB
Python
Raw Normal View History

2022-12-02 18:31:37 +10:00
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
2022-11-12 20:36:08 +10:00
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)
2022-11-12 20:36:08 +10:00
dick_size = (Column(Integer))
2022-11-13 22:56:33 +10:00
datetimes = (Column(DateTime))
2022-12-01 19:43:36 +10:00
chat_id = Column(BIGINT)
2022-12-02 18:31:37 +10:00
2022-12-04 16:21:45 +10:00
2022-12-04 16:21:45 +10:00
session.close()
engine.dispose()
2022-12-02 18:31:37 +10:00
# 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)
2022-11-14 00:23:03 +10:00
#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
2022-11-08 22:06:11 +10:00
2022-11-12 20:36:08 +10:00
# def adding():
2022-11-09 22:52:44 +10:00
2022-11-12 20:36:08 +10:00
# session.add()
# session.commit()
2022-11-09 22:52:44 +10:00