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
from .. import engine
#engine = create_engine(app.config['DATABASE_URI'])
# engine = create_engine(app.config['DATABASE_URI'],pool_size=5000,pool_pre_ping=True,pool_recycle=3600)
# engine = create_engine(app.config['DATABASE_URI'],pool_size=5000,max_overflow=100,pool_pre_ping=True,pool_recycle=3600)
# engine = create_engine(app.config['DATABASE_URI'], poolclass=None,pool_size=5000,max_overflow=100,pool_pre_ping=True,pool_recycle=3600)
class MSteps():
def __init__(self):
try:
self.meta = MetaData()
self.m_work_type = Table("m_steps", self.meta, autoload_with=engine)
except Exception as e:
print(e)
def usp_get_steps(self,step_no,society_id):
sets = []
try:
connection = engine.raw_connection()
cursor = connection.cursor()
cursor.callproc("usp_get_steps",[step_no,society_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:
# Return the connection to the pool (won't actually close).
connection.close()
for index,value in enumerate(sets) :
if index == 0:
if len(value) == 0:
current_step = 0
else:
current_step = value[0]
# cur_step = current_step['step_no']
if index == 1:
if len(value) == 0:
pre_step = 0
else:
previous_step = value[0]
pre_step = previous_step['step_no']
if index == 2:
if len(value) == 0:
nxt_step = 0
else:
next_step = value[0]
nxt_step = next_step['step_no']
return current_step,pre_step,nxt_step
def getlastStepNo(self,society_id):
with engine.connect() as conn:
stmt = text("select step_no from m_steps where society_id=:society_id order by step_no desc limit 1;")
results = conn.execute(stmt.bindparams(society_id=society_id))
conn.close()
return results.first()
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists