Sindbad~EG File Manager
from flask import session
from flask import request, Blueprint, jsonify
from sqlalchemy import create_engine, select, MetaData, Table,text
from sqlalchemy.sql import and_, or_
from core import app
engine = create_engine(app.config['DATABASE_URI'],pool_pre_ping=True,pool_recycle=3600)
engine_conf = create_engine(app.config['CONF_DB_URI'],pool_pre_ping=True,pool_recycle=3600)
class NotificationModel():
def __init__(self):
try:
# conference
self.meta = MetaData()
self.notification_logs = Table("notification_logs", self.meta, autoload_with=engine_conf)
except Exception as e:
print(e)
def GetUserCommitment(self,user_id,date,time,conf_id):
sets = []
try:
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_get_user_commmintment_notification",[user_id,date,time,conf_id])
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:
connection.commit()
# Return the connection to the pool (won't actually close).
connection.close()
# print(sets)
return sets[0]
def saveNotificationLogsMysql(self,conf_id,data):
with engine_conf.connect() as conn:
result = conn.execute(self.notification_logs.insert(),data)
conn.commit()
return 'Success'
def GetTestCommitmentUsers(self,conf_id):
with engine.connect() as conn:
stmt=text("SELECT u.*,us.full_name FROM numerote_primary_db_conf.fb_users u inner join users us on u.user_id=us.user_id where u.is_test_user = 1 group by u.user_id order by us.full_name desc;")
# print(stmt)
result=conn.execute(stmt).all()
results = [dict(r._mapping) for r in result] if result else None
conn.close()
return results
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists