Sindbad~EG File Manager
from flask import session
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_size=5000,pool_pre_ping=True,pool_recycle=3600)
# engine = create_engine('')
class UserModel():
def __init__(self):
try:
self.meta = MetaData()
self.payments = Table("payments", self.meta, autoload_with=engine)
except Exception as e:
print(e)
def insert_delegates(self, data,unique_id):
with engine.connect() as conn:
result = conn.execute(self.payments.insert(), data)
conn.commit()
stmt = text("select * from payments where unique_id = "+"'"+ unique_id+ "' "+ ";")
result = conn.execute(stmt)
output = result.fetchone()
last_p_id = output.p_id
return last_p_id
def get_delegate_by_pid(self,id):
with engine.connect() as conn:
stmt = text(" select * from payments where p_id = "+str(id)+" ;")
# stmt = select([self.payments]).where(self.payments.c.p_id.in_([id]))
result = conn.execute(stmt).one_or_none()
return dict(result._mapping) if result else None
# last_insert_id,payment_id
def update_payment_id(self,p_id,status, payment_id,method):
with engine.connect() as conn:
stmt = self.payments.update().values({"payment_status":status, "payment_id":payment_id,"method":method}).where(self.payments.c.p_id.in_([p_id]))
result = conn.execute(stmt)
conn.commit()
return result
def getApikeys(self):
with engine.connect() as conn:
stmt = text('select * from app_master;')
result = conn.execute(stmt).all()
results = [dict(r._mapping) for r in result] if result else None
return results
def getGatewaySettins(self,am_id):
with engine.connect() as conn:
stmt = text('select * from gateway_settings where am_id = '+str(am_id)+' limit 1;')
result = conn.execute(stmt).all()
results = [dict(r._mapping) for r in result] if result else None
return results
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists