Sindbad~EG File Manager
from sqlalchemy import create_engine, MetaData, Table, insert, select,update,delete,text
from sqlalchemy.sql import and_, or_
from core import app
import json
engine = create_engine(app.config['DATABASE_URI'],pool_size=5000,pool_pre_ping=True,pool_recycle=3600)
class DashboardModel():
def __init__(self):
try:
self.meta = MetaData()
except Exception as e:
print("Table not found",e)
def get_reg_desk_count(self,conf_id,view_type,date,user_id):
print(conf_id,view_type,date,user_id)
sets = []
try:
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_conf_get_reg_desk_dashboard_count",[(conf_id or None),(view_type or None),(date or None),(user_id or None)])
while 1:
names = [c[0] for c in cursor.description]
set_ = []
while 1:
row_raw = cursor.fetchone()
if row_raw is None:
break
row = dict(zip(names, row_raw))
set_.append(row)
sets.append(list(set_))
if cursor.nextset() is None:
break
# nextset() doesn't seem to be sufficiant to tell the end.
if cursor.description is None:
break
finally:
# Return the connection to the pool (won't actually close).
connection.commit()
connection.close()
return sets
def get_badge_issued_count(self,conf_id,conf_schema):
with engine.connect() as conn:
stmt = text("select case when is_spot =1 then 'SPOT' else 'ONLINE' end as reg_type,role,count(*) as badge_issused_count from "+str(conf_schema)+".delegates where conference_id = "+str(conf_id)+" and signed_on is not null group by role,is_spot order by is_spot ASC,role ASC;")
result = conn.execute(stmt).all()
conn.close()
return [dict(r._mapping) for r in result] if result else None
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists