Sindbad~EG File Manager

Current Path : /home/numerotech/hs.numerotech.com/scan_v1/core/model/
Upload File :
Current File : //home/numerotech/hs.numerotech.com/scan_v1/core/model/LocalModel.py

from sqlalchemy import create_engine, MetaData, Table, insert, null, select,update,delete,text
from sqlalchemy.sql import and_, or_
from sqlalchemy import asc, desc
from core import app
import json
from datetime import timedelta,date,datetime,time

#engine = create_engine(app.config['DATABASE_URI'])
# engine      = create_engine(app.config['DATABASE_URI'],pool_recycle=3600,future=True)
# engine_fk   = create_engine(app.config['DATABASE_URI_FK'],pool_recycle=3600,future=True)
engine_conf = create_engine(app.config['DATABASE_URI_CONF'],pool_recycle=3600,future=True)

class LocalModel():
	def __init__(self):
		try:
			self.meta = MetaData()
		except Exception as e:
			print(e)

	def get_not_sync_hall_scan_data(self,conf_id,conf_key,hall_id,scan_table_name):
		with engine_conf.connect() as conn:
			stmt  = text("select * from "+scan_table_name+" where new_sync_at is null;")
			print("stmt---",stmt)
			# stmt  = text("select * from "+scan_table_name+" where  entry_at is not null and exist_at is null;")	
			result  = conn.execute(stmt).all()
			results = [dict(r._mapping) for r in result] if result else None
			return results



	def update_last_sync_at_from_live(self,last_sync_at,scan_table_name):
		with engine_conf.connect() as conn:
			try:
				stmt      = text(f"update {scan_table_name} set new_sync_at = '{last_sync_at}'  where created_at < '{last_sync_at}' and new_sync_at is null ;")
				restult_1 = conn.execute(stmt)
				conn.commit()
				return "success"
			except Exception as e:
				print("Error: ",e)
				return str(e)


	

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