Skip to content

Commit

Permalink
renamed function to follow convention of naming
Browse files Browse the repository at this point in the history
  • Loading branch information
feyruzb committed Aug 16, 2024
1 parent 8e780d2 commit e39cd16
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions web/server/codechecker_server/api/product_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,11 @@ def getProductConfiguration(self, product_id):
return prod

@timeit
def addProduct_Support(self,product_info):
def add_product_support(self, product_info):
"""
Creates a database for the given product,
to assist add product function that connect to already existing database
to assist add product function that connect to
already existing database
"""
# Extract connection details
if product_info.engine == 'sqlite':
Expand All @@ -326,13 +327,13 @@ def addProduct_Support(self,product_info):
db_port = int(product_info.port)
db_user = convert.from_b64(product_info.username_b64)
db_pass = convert.from_b64(product_info.password_b64)
db_name = product_info.database if product_info.database else None
db_name = product_info.database or None
if db_name is None:
raise Exception("Database name is not provided")
except Exception as e:
raise Exception("Invalid connection details")
raise ValueError("Database name is not provided")
except Exception as x:
raise ValueError("Invalid database connection details") from x

# Create an engine for database to connect and create a new database
# Create an engine for database to connect to
engine_url = URL.URL(
drivername=db_engine,
username=db_user,
Expand All @@ -344,7 +345,8 @@ def addProduct_Support(self,product_info):
engine = create_engine(engine_url)
conn = engine.connect()
conn.execute("commit")
#check connection

# check connection
try:
conn.execute(f"CREATE DATABASE {db_name}")
return True
Expand All @@ -358,7 +360,7 @@ def addProduct_Support(self,product_info):
return False

@timeit
def addProduct(self, product): # work in progress
def addProduct(self, product):
"""
Add the given product to the products configured by the server.
"""
Expand Down

0 comments on commit e39cd16

Please sign in to comment.