1313import os
1414import random
1515
16+ from sqlalchemy import text
1617from sqlalchemy .sql .expression import and_
1718
1819from sqlalchemy import create_engine , exc
@@ -244,7 +245,7 @@ def getCurrentProduct(self):
244245 msg )
245246
246247 with DBSession (self .__session ) as session :
247- prod = session .query ( Product ). get (self .__product .id )
248+ prod = session .get (Product , self .__product .id )
248249
249250 if not prod :
250251 msg = "The product requested has been disconnected from the " \
@@ -270,7 +271,7 @@ def getProductConfiguration(self, product_id):
270271 ], {'productID' : product_id })
271272
272273 with DBSession (self .__session ) as session :
273- product = session .query ( Product ). get (product_id )
274+ product = session .get (Product , product_id )
274275 if product is None :
275276 msg = f"Product with ID { product_id } does not exist!"
276277 LOG .error (msg )
@@ -354,7 +355,7 @@ def __create_product_database(self, product):
354355 db_pass = convert .from_b64 (product_info .password_b64 )
355356 db_name = product_info .database
356357
357- engine_url = URL (
358+ engine_url = URL . create (
358359 drivername = db_engine ,
359360 username = db_user ,
360361 password = db_pass ,
@@ -365,9 +366,9 @@ def __create_product_database(self, product):
365366 engine = create_engine (engine_url )
366367 try :
367368 with engine .connect () as conn :
368- conn .execute ("commit" )
369+ conn .execute (text ( "commit" ) )
369370 LOG .info ("Creating database '%s'" , db_name )
370- conn .execute (f"CREATE DATABASE { db_name } " )
371+ conn .execute (text ( f"CREATE DATABASE { db_name } " ) )
371372 conn .close ()
372373 except exc .ProgrammingError as e :
373374 LOG .error ("ProgrammingError occurred: %s" , str (e ))
@@ -555,7 +556,7 @@ def editProduct(self, product_id, new_config):
555556 new_configuration.
556557 """
557558 with DBSession (self .__session ) as session :
558- product = session .query ( Product ). get (product_id )
559+ product = session .get (Product , product_id )
559560 if product is None :
560561 msg = f"Product with ID { product_id } does not exist!"
561562 LOG .error (msg )
@@ -735,7 +736,7 @@ def editProduct(self, product_id, new_config):
735736 LOG .info ("Product configuration edited and saved successfully." )
736737
737738 if product_needs_reconnect :
738- product = session .query ( Product ). get (product_id )
739+ product = session .get (Product , product_id )
739740 LOG .info ("Product change requires database reconnection..." )
740741
741742 LOG .debug ("Disconnecting..." )
@@ -762,7 +763,7 @@ def removeProduct(self, product_id):
762763 self .__require_permission ([permissions .SUPERUSER ])
763764
764765 with DBSession (self .__session ) as session :
765- product = session .query ( Product ). get (product_id )
766+ product = session .get (Product , product_id )
766767 if product is None :
767768 msg = f"Product with ID { product_id } does not exist!"
768769 LOG .error (msg )
0 commit comments