Compare commits

..

2 Commits

Author SHA1 Message Date
Simple_Not
d596fe9af7 #DICKBOT-3 Done. Kool one! 2023-06-20 21:10:25 +10:00
Simple_Not
c0800241dc #DICKBOT-3 Done. Kool one! 2023-06-20 21:10:04 +10:00

56
exporto.py Normal file
View File

@ -0,0 +1,56 @@
from sqlalchemy import create_engine, Integer, String, BIGINT, Column, DateTime
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from sqlalchemy import select, update
from flask import Flask
app = Flask(__name__)
engine = create_engine('postgresql+psycopg2://postgres:postgres@postgres.vdk2ch.ru:5432/jack_bot', echo=True)
Session = sessionmaker(bind=engine)
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)
def get_top_dicks():
session = Session()
top = session.query(user.user_fullname, user.dick_size, user.user_id, user.chat_id).all()
session.close()
return top
@app.route('/metrics')
def metrics():
metrics = ""
for dick in get_top_dicks():
metrics += 'pipisio{user="%s", user_id="%s", chat_id="%s"} %s\n' % (dick[0], dick[2], dick[3], dick[1])
return metrics
if __name__ == '__main__':
app.run(host='0.0.0.0', port=9992)
engine.dispose()