Sindbad~EG File Manager

Current Path : /home/numerotech/conf-scan.numerotech.com/conference_scan/core/model/
Upload File :
Current File : //home/numerotech/conf-scan.numerotech.com/conference_scan/core/model/ConfDashboardModel.py

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)+";")

			result = conn.execute(stmt).all()
			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 * from conference c inner join society_applications s on s.conf_id = c.conf_id and app_type_id = 2  inner 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;")
			result = conn.execute(stmt)
			result = result.one_or_none()
			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.one_or_none()
			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()
			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

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists