Sindbad~EG File Manager

Current Path : /proc/self/root/home/numerotech/flutter-api.numerotech.com/flutter_api_v1/core/model/
Upload File :
Current File : //proc/self/root/home/numerotech/flutter-api.numerotech.com/flutter_api_v1/core/model/APIModel.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'])

class APIModel():
	def __init__(self):
		try:
			self.meta           	= MetaData()
			self.contactinfoTable   = Table("contactinfoTable", self.meta,  autoload_with=engine)
			
		except Exception as e:
			print(e)


	def getUsers(self):
		with engine.connect() as conn:
			stmt = text("select * from contactinfoTable;")
			results = conn.execute(stmt).all()
			return [dict(r._mapping) for r in results] if results else None
			

	def insertUsers(self,data):
		with engine.connect() as conn:
			result = conn.execute(self.contactinfoTable.insert(), data)
			conn.commit()
			return "success"


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