Hi everyone,
I'm new to python for forgive me if my fundamental idea of this concept is way off.
I have 2 python programs. One of them contains the following function. It's purpose being to connect to a db and run a query. I want to be able to pass some variable to it, and use the variables contained value in the sql query (note the ** portion of query):
Thank you in advance.
I'm new to python for forgive me if my fundamental idea of this concept is way off.
I have 2 python programs. One of them contains the following function. It's purpose being to connect to a db and run a query. I want to be able to pass some variable to it, and use the variables contained value in the sql query (note the ** portion of query):
def updateSent(): cnxn = pyodbc.connect('UID='+dbUser+';PWD='+dbPassword+';DSN='+dbHost) cursor = cnxn.cursor() update_stmt = "UPDATE WKM_sms_outbound SET status = 'sent' WHERE msg_id = **value from msgId variable**" cursor.execute(update_stmt)Then be able to call it from program 2 like this:
from program1 import updateSent updateSent(msgId)Is this possible? I'd imagine that I'm doing it incorrectly, but have googled for a while now and am unable to find exactly what I'm looking for.
Thank you in advance.