@@ -25,7 +25,7 @@ class Query:
2525 """
2626
2727 def query (
28- self , selectStatement : str , sansTran : bool = False , returnAsDict : bool = False , alias : Optional [str ] = None
28+ self , selectStatement : str , sansTran : bool = False , returnAsDict : bool = False , alias : Optional [str ] = None , parameters : Optional [ List ] = None
2929 ):
3030 """
3131 Uses the input ``selectStatement`` to query for the values that will be returned as a list of tuples. Set
@@ -79,7 +79,7 @@ def query(
7979 if cur and not sansTran :
8080 db_connection .client .rollback ()
8181
82- def row_count (self , selectStatement : str , sansTran : bool = False , alias : Optional [str ] = None ):
82+ def row_count (self , selectStatement : str , sansTran : bool = False , alias : Optional [str ] = None , parameters : Optional [ List ] = None ):
8383 """
8484 Uses the input ``selectStatement`` to query the database and returns the number of rows from the query. Set
8585 optional input ``sansTran`` to True to run command without an explicit transaction commit or rollback.
@@ -124,7 +124,7 @@ def row_count(self, selectStatement: str, sansTran: bool = False, alias: Optiona
124124 if cur and not sansTran :
125125 db_connection .client .rollback ()
126126
127- def description (self , selectStatement : str , sansTran : bool = False , alias : Optional [str ] = None ):
127+ def description (self , selectStatement : str , sansTran : bool = False , alias : Optional [str ] = None , parameters : Optional [ List ] = None ):
128128 """
129129 Uses the input ``selectStatement`` to query a table in the db which will be used to determine the description. Set
130130 optional input ``sansTran` to True to run command without an explicit transaction commit or rollback.
@@ -331,7 +331,7 @@ def execute_sql_script(self, sqlScriptFileName: str, sansTran: bool = False, ali
331331 if cur and not sansTran :
332332 db_connection .client .rollback ()
333333
334- def execute_sql_string (self , sqlString : str , sansTran : bool = False , alias : Optional [str ] = None ):
334+ def execute_sql_string (self , sqlString : str , sansTran : bool = False , alias : Optional [str ] = None , parameters : Optional [ List ] = None ):
335335 """
336336 Executes the sqlString as SQL commands. Useful to pass arguments to your sql. Set optional input `sansTran` to
337337 True to run command without an explicit transaction commit or rollback.
@@ -507,7 +507,7 @@ def call_stored_procedure(
507507 if cur and not sansTran :
508508 db_connection .client .rollback ()
509509
510- def __execute_sql (self , cur , sql_statement : str , omit_trailing_semicolon : Optional [bool ] = None ):
510+ def __execute_sql (self , cur , sql_statement : str , omit_trailing_semicolon : Optional [bool ] = None , parameters : Optional [ List ] = None ):
511511 """
512512 Runs the `sql_statement` using `cur` as Cursor object.
513513 Use `omit_trailing_semicolon` parameter (bool) for explicit instruction,
@@ -519,5 +519,7 @@ def __execute_sql(self, cur, sql_statement: str, omit_trailing_semicolon: Option
519519 omit_trailing_semicolon = self .omit_trailing_semicolon
520520 if omit_trailing_semicolon :
521521 sql_statement = sql_statement .rstrip (";" )
522+ if parameters is None :
523+ parameters = []
522524 logger .debug (f"Executing sql: { sql_statement } " )
523- return cur .execute (sql_statement )
525+ return cur .execute (sql_statement , parameters )
0 commit comments