#DICKBOT-3 Done. Kool one!
This commit is contained in:
parent
8d12efb902
commit
c0800241dc
56
exporto.py
Normal file
56
exporto.py
Normal 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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
from flask import Flask
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@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()
|
Loading…
Reference in New Issue
Block a user