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_recycle=3600)
class ConfDashboardModel():
def __init__(self):
try:
self.meta = MetaData()
self.conference = Table("conference", self.meta, autoload_with=engine)
self.conference_active = Table("conference_active", self.meta, autoload_with=engine)
except Exception as e :
print("Table not found",e)
def get_conf_dashboard_data(self,conf_id):
with engine.connect() as conn:
stmt = text("select * from conference_active where conf_id = "+str(conf_id)+" and is_visible = 1 order by order_by ASC;")
result = conn.execute(stmt).all()
conn.close()
return [dict(r._mapping) for r in result] if result else None
def GetConf(self,conf_id,conf_key):
with engine.connect() as conn:
stmt = text("select c.* from conference c left join society_applications s on s.conf_id = c.conf_id and app_type_id = 2 left join mail_setting m on s.mail_setting_id = m.mail_setting_id where c.conf_id = "+str(conf_id)+" and c.conf_key = '"+conf_key+"' limit 1;")
print(stmt)
result = conn.execute(stmt)
result = result.first()
conn.close()
return dict(result._mapping) if result else None
def get_dashboard_id(self,conf_id,active_id):
with engine.connect() as conn:
stmt = text("select * from conference_active where conf_id = "+str(conf_id)+" and active_id = "+str(active_id)+" limit 1;")
result = conn.execute(stmt)
result = result.first()
conn.close()
return dict(result._mapping) if result else None
def update_dashboard_setting(self,active_id,update_data):
with engine.connect() as conn:
stmt = self.conference_active.update().where(self.conference_active.c.active_id.in_([active_id])).values(update_data)
result = conn.execute(stmt)
conn.commit()
conn.close()
return 'success' if result else 'fail'
def get_overall_conf_data(self,conf_id,conf_shema):
sets = []
try:
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_conf_get_overall_conf_data",[(conf_id or None),(conf_shema or None)])
while 1:
#(column_name, type_, ignore_, ignore_, ignore_, null_ok, column_flags)
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.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
# Purpose : Setup conference active dashboard form
# Created At : 2024-10-30 10:14 By Ramya
def get_conference_active(self,conf_id):
with engine.connect() as conn:
stmt = text("select * from conference_active where conf_id ="+str(conf_id)+" ;")
result = conn.execute(stmt).all()
conn.close()
return [dict(r._mapping) for r in result] if result else None
def get_active_key(self,conf_id):
with engine.connect() as conn:
stmt = text("select group_concat(active_key separator ''',''') as active_key from conference_active where conf_id ="+str(conf_id)+" ;")
result = conn.execute(stmt).fetchone()
conn.close()
return dict(result._mapping) if result else None
def get_pending_conference_active(self,active_keys):
with engine.connect() as conn:
where_con = " "
if active_keys :
where_con = " where active_key not in ('"+str(active_keys)+"')"
stmt = text("select * from m_conference_active "+str(where_con)+" ")
result = conn.execute(stmt).all()
conn.close()
return [dict(r._mapping) for r in result] if result else None
def common_update_query(self,stmt_1):
with engine.connect() as conn:
stmt2 = text("set sql_safe_updates = 0 ;")
conn.execute(stmt2)
conn.commit()
stmt_1 = text(stmt_1)
result = conn.execute(stmt_1)
conn.commit()
conn.close()
return 'success' if result else 'fail'
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists