@@ -311,10 +311,11 @@ def getProductConfiguration(self, product_id):
311
311
return prod
312
312
313
313
@timeit
314
- def addProduct_Support (self ,product_info ):
314
+ def add_product_support (self , product_info ):
315
315
"""
316
316
Creates a database for the given product,
317
- to assist add product function that connect to already existing database
317
+ to assist add product function that connect to
318
+ already existing database
318
319
"""
319
320
# Extract connection details
320
321
if product_info .engine == 'sqlite' :
@@ -326,13 +327,13 @@ def addProduct_Support(self,product_info):
326
327
db_port = int (product_info .port )
327
328
db_user = convert .from_b64 (product_info .username_b64 )
328
329
db_pass = convert .from_b64 (product_info .password_b64 )
329
- db_name = product_info .database if product_info . database else None
330
+ db_name = product_info .database or None
330
331
if db_name is None :
331
- raise Exception ("Database name is not provided" )
332
- except Exception as e :
333
- raise Exception ("Invalid connection details" )
332
+ raise ValueError ("Database name is not provided" )
333
+ except Exception as x :
334
+ raise ValueError ("Invalid database connection details" ) from x
334
335
335
- # Create an engine for database to connect and create a new database
336
+ # Create an engine for database to connect to
336
337
engine_url = URL .URL (
337
338
drivername = db_engine ,
338
339
username = db_user ,
@@ -344,7 +345,8 @@ def addProduct_Support(self,product_info):
344
345
engine = create_engine (engine_url )
345
346
conn = engine .connect ()
346
347
conn .execute ("commit" )
347
- #check connection
348
+
349
+ # check connection
348
350
try :
349
351
conn .execute (f"CREATE DATABASE { db_name } " )
350
352
return True
@@ -358,7 +360,7 @@ def addProduct_Support(self,product_info):
358
360
return False
359
361
360
362
@timeit
361
- def addProduct (self , product ): # work in progress
363
+ def addProduct (self , product ):
362
364
"""
363
365
Add the given product to the products configured by the server.
364
366
"""
0 commit comments