@ -31,49 +31,24 @@ def SelectBDTemplate(a_TableName):
return SQLRequestToBD ( f ' SELECT * FROM { a_TableName } ' )
return SQLRequestToBD ( f ' SELECT * FROM { a_TableName } ' )
return SelectBD
return SelectBD
def SQLRequestToBDCommit ( a_Request : str ) :
def SQLRequestToBD ( a_Request : str , commit = False , return_error = False , param = None ) :
return SQLRequestToBD1Commit ( a_Request , None )
def SQLRequestToBD1Commit ( a_Request : str , a_Param1 ) :
return SQLRequestToBD2Commit ( a_Request , a_Param1 , None )
def SQLRequestToBD2Commit ( a_Request : str , a_Param1 , a_Param2 ) :
return SQLRequestToBD3Common ( a_Request , True , a_Param1 , a_Param2 , None )
def SQLRequestToBD3Commit ( a_Request : str , a_Param1 , a_Param2 , a_Param3 ) :
return SQLRequestToBD3Common ( a_Request , True , a_Param1 , a_Param2 , a_Param3 )
def SQLRequestToBD ( a_Request : str ) :
return SQLRequestToBD1 ( a_Request , None )
def SQLRequestToBD1 ( a_Request : str , a_Param1 ) :
return SQLRequestToBD2 ( a_Request , a_Param1 , None )
def SQLRequestToBD2 ( a_Request : str , a_Param1 , a_Param2 ) :
return SQLRequestToBD3Common ( a_Request , False , a_Param1 , a_Param2 , None )
def SQLRequestToBD3 ( a_Request : str , a_Param1 , a_Param2 , a_Param3 ) :
return SQLRequestToBD3Common ( a_Request , False , a_Param1 , a_Param2 , a_Param3 )
def SQLRequestToBD3Common ( a_Request : str , a_Commit : bool , a_Param1 , a_Param2 , a_Param3 ) :
db = sqlite3 . connect ( GetBDFileName ( ) )
db = sqlite3 . connect ( GetBDFileName ( ) )
cursor = db . cursor ( )
cursor = db . cursor ( )
result = [ ]
result = [ ]
error = None
try :
try :
if not a_Param3 is None :
if not param is None :
cursor . execute ( a_Request , ( a_Param1 , a_Param3 , a_Param3 ) )
cursor . execute ( a_Request , ( param ) )
elif not a_Param2 is None :
cursor . execute ( a_Request , ( a_Param1 , a_Param2 ) )
elif not a_Param1 is None :
cursor . execute ( a_Request , ( a_Param1 ) )
else :
else :
cursor . execute ( a_Request )
cursor . execute ( a_Request )
result = cursor . fetchall ( )
result = cursor . fetchall ( )
if a_C ommit:
if commit :
db . commit ( )
db . commit ( )
except sqlite3 . Error as e :
except sqlite3 . Error as e :
log . Error ( f ' Ошибка при обработке запроса [ { a_Request } ]: { str ( e ) } ' )
log . Error ( f ' Ошибка при обработке запроса [ { a_Request } ]: { str ( e ) } ' )
result = " Ошибка sqlite3: " + str ( e )
error = " Ошибка sqlite3: " + str ( e )
cursor . close ( )
cursor . close ( )
db . close ( )
db . close ( )
if return_error :
return result , error
return result
return result