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'], poolclass=None,pool_size=5000,max_overflow=100,pool_pre_ping=True,pool_recycle=3600)
class UserOthersociety():
def __init__(self):
try:
self.meta = MetaData()
self.user_other_society = Table("user_other_society", self.meta, autoload_with=engine)
except Exception as e:
print(e)
def get_othersociety(self,user_other_society_id):
with engine.connect() as conn:
stmt = select(self.user_other_society).where(self.user_other_society.c.user_other_society_id.in_([user_other_society_id]))
result = conn.execute(stmt)
output = result.first()
conn.close()
if output:
return dict(output._mapping)
else:
return None
def delete_othersociety(self,user_other_society_id):
with engine.connect() as conn:
stmt = text("delete from user_other_society WHERE user_other_society_id IN("+str(user_other_society_id)+")")
result = conn.execute(stmt)
conn.commit()
conn.close()
return result
def count_othersociety_user_id(self,user_id):
with engine.connect() as conn:
stmt = text("SELECT COUNT(user_id) as user_id FROM user_other_society where user_id="+ str(user_id) +";")
results = conn.execute(stmt).first()
conn.close()
if results:
return dict(results._mapping)
else:
return None
# ganesan
# insert or update qualification
def update_or_insert_othersociety(self,user_id,user_other_society_id,data):
with engine.connect() as conn:
if (int(user_other_society_id) > 0):
data.pop("created_at")
stmt = self.user_other_society.update().where(self.user_other_society.c.user_other_society_id.in_([user_other_society_id])).values(data)
result = conn.execute(stmt)
else :
# insert block
result = conn.execute(self.user_other_society.insert(), data)
conn.commit()
stmt = text("select * from user_other_society where user_id= "+str(user_id)+";")
results = conn.execute(stmt).all()
conn.close()
return [dict(r._mapping) for r in results] if results else None
def get_othersociety_by_user(self,user_id):
with engine.connect() as conn:
stmt = text("select * from user_other_society where user_id= "+str(user_id)+";")
results = conn.execute(stmt).all()
conn.close()
return [dict(r._mapping) for r in results] if results else None
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists