Apr-25-2019, 06:15 PM
Hi,
I've just decided to try and learn Python, I've got very limited experience with programming languages, but have been working with PowerShell for a while so hoping this well help me.
So basically I'm trying to learn Python but developing my own App, I'm trying to get the app to check my Azure SQL DB for a table and if it doesn't exist, create it.
Im trying to use a IF statement to query the DB using the below, Ive excluded the connection details, as i can get the Table created so i know the connction details are good.
Hope this makes sense.
I've just decided to try and learn Python, I've got very limited experience with programming languages, but have been working with PowerShell for a while so hoping this well help me.
So basically I'm trying to learn Python but developing my own App, I'm trying to get the app to check my Azure SQL DB for a table and if it doesn't exist, create it.
Im trying to use a IF statement to query the DB using the below, Ive excluded the connection details, as i can get the Table created so i know the connction details are good.
sql_check = """ SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'employee'""" cnxn = pyodbc.connect('DRIVER='+driver+';SERVER='+server+';PORT=1433;DATABASE='+database+';UID='+username+';PWD='+ password) def check_database_table(): cursor = cnxn.cursor() r = cursor.execute(sql_check) print(r)And then i was going to do something like if r = null then do something, but i do get a value back from r
Hope this makes sense.