Sindbad~EG File Manager
from sqlalchemy import create_engine, MetaData, Table, insert, select,update,delete,text
from sqlalchemy.sql import and_, or_
from sqlalchemy import text
from core import app
import json
from .. import engine,engine_conf_db,engine_fk_db
import sqlite3
import pandas as pd
engine = create_engine(app.config['DATABASE_URI'],pool_size=5000,pool_pre_ping=True,pool_recycle=3600)
class PhotoModel():
def __init__(self):
try:
self.meta = MetaData()
self.conference = Table("conference", self.meta, autoload_with=engine)
except Exception as e:
print("table not found",e)
def get_conf_photo(self,conf_id,conf_key):
with engine.connect() as conn:
stmt = text("select * from conference c inner join societies s on s.society_id = c.society_id inner join society_applications sa on sa.conf_id = c.conf_id and sa.app_type_id = 2 left join mail_setting ms on ms.mail_setting_id = sa.mail_setting_id left join daily_digest_mail_color_template dc on dc.conf_id = c.conf_id where c.conf_id = "+str(conf_id)+" and c.conf_key='"+str(conf_key)+"' and sa.app_type_id = 2 ;")
result = conn.execute(stmt)
result = result.fetchone()
return dict(result._mapping) if result else None
def delegateDataByDelegateNo(self,conf_id,conf_key,delegate_no,is_gen_number):
with engine.connect() as conn:
if is_gen_number == 'ref_number':
stmt = text("select * from delegates where conference_id = "+str(conf_id)+" and del_status_id = 2 and ref_no = '"+str(delegate_no)+"' ;")
else:
stmt = text("select * from delegates where conference_id = "+str(conf_id)+" and del_status_id = 2 and delegate_no = "+str(delegate_no)+" ;")
result = conn.execute(stmt).one_or_none()
return dict(result._mapping) if result else None
def delegateDataByDelegateId(self,conf_id,conf_key,delegate_id):
with engine.connect() as conn:
stmt = text("select * from delegates where conference_id = "+str(conf_id)+" and delegate_id = "+str(delegate_id)+" ;")
result = conn.execute(stmt).one_or_none()
return dict(result._mapping) if result else None
def check_delegate_by_del_no(self,del_no,conf_id):
with engine.connect() as conn:
stmt = text("select * from delegates where delegate_no = "+str(del_no)+" and conf_id = "+str(conf_id)+" ;")
print(stmt)
result = conn.execute(stmt).one_or_none()
results = dict(result._mapping) if result else None
return results
def UpdateDelegatePhoto(self,update_stmt,delegate_id,conf_id):
with engine.connect() as conn:
safe_update = text("SET SQL_SAFE_UPDATES = 0 ; ")
result_1 = conn.execute(safe_update)
stmt = text(update_stmt)
# stmt = self.delegates.update().where(self.delegates.c.delegate_id.in_([delegate_id])).values(data)
result = conn.execute(stmt)
conn.commit()
if result:
return result
else :
return None
def delete_file_nameand_path(self,conf_id,delegate_id):
with engine.connect() as conn:
try:
stmt = text("Update delegates SET del_img_path = null ,del_img_filename = null where conference_id = "+str(conf_id)+" and delegate_id = "+str(delegate_id)+"; ")
print("---------",stmt)
safe_update = text("SET SQL_SAFE_UPDATES = 0 ")
result = conn.execute(safe_update)
results = conn.execute(stmt)
conn.commit()
return "success"
except Exception as e:
return str(e)
def delegateDataByDelegateuser_uuid(self,conf_id,user_uuid):
with engine.connect() as conn:
stmt = text("select * from delegates where conference_id = "+str(conf_id)+" and user_uuid = '"+(user_uuid)+"' ;")
result = conn.execute(stmt).one_or_none()
return dict(result._mapping) if result else None
def update_file_nameand_path(self,user_id,society_id,del_img_path,del_img_filename,curr_dt):
with engine.connect() as conn:
try:
# stmt = text("update conference c inner join delegates d on d.conference_id = c.conf_id inner join users u on d.user_id = u.user_id SET d.del_img_path = '"+del_img_path+"',d.del_img_filename = '"+del_img_filename+"' where c.society_id = "+str(society_id)+" and c.is_active = 1 and c.conf_end_time > '2024-08-15 23:59:00' and d.delegate_no > 0 and d.user_id = "+str(user_id)+" ;")
stmt = text("update delegates d inner join users u on u.user_id = d.user_id inner join conference c on c.conf_id = d.conference_id SET d.del_img_path = '"+del_img_path+"',d.del_img_filename = '"+del_img_filename+"' where u.society_id = "+str(society_id)+" and c.is_active = 1 and c.conf_end_time > '"+curr_dt+"' and delegate_no is not null and d.user_id = "+str(user_id)+" ;")
safe_update = text("SET SQL_SAFE_UPDATES = 0 ")
result = conn.execute(safe_update)
results = conn.execute(stmt)
conn.commit()
return "success"
except Exception as e:
return str(e)
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists