Run Sql server store procedure using Python

3889
2
Jump to solution
05-08-2015 01:42 PM
Jose_LuisGarcinuno-Oporto
New Contributor III

I wonder if someone can help me with this, I been searching on internet and so far I know that there is a module called ODBC or pyODBC which allow to do this, in my python window I wrote

import pyodbc and I got a error message, so it seems that it is not installed How I can get it.

Thanks

0 Kudos
1 Solution

Accepted Solutions
SamuelTompsett
Occasional Contributor II
0 Kudos
2 Replies
SamuelTompsett
Occasional Contributor II
0 Kudos
Jose_LuisGarcinuno-Oporto
New Contributor III

import pyodbc

conn = pyodbc.connect('DRIVER={SQL Server};SERVER=test;DATABASE=Dev;Integrated Security=true')

if (conn == False):

    print "Error"

a = 'p_RECENT_Bulk_Import_test'

cursor1 = conn.cursor()

cursor1.execute(a)

cursor1.close()

del cursor1

conn.close()

Thank you Samuel for your help, I did install that module, now when I run the code above I did not ge any record populate into the table ( the store procedure run fine in sql its take an txt file and add all the record into a table), so I guess is something in my code, do I need to go through each record like using a sql fetch?.

thank.

0 Kudos