33 lines
650 B
Python
33 lines
650 B
Python
import pyodbc
|
|
|
|
try:
|
|
connection = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER=.;DATABASE=SampleDB;Trusted_Connection=yes')
|
|
|
|
cursor = connection.cursor()
|
|
|
|
|
|
sql_cmd="""
|
|
create or alter procedure usp_cus_details (@cus_id int, @out nvarchar(max) output)
|
|
as
|
|
select * from tblCustomers where id = @cus_id
|
|
|
|
"""
|
|
|
|
cursor.execute(sql_cmd)
|
|
connection.commit()
|
|
|
|
print("stored procedure successfully created or altered")
|
|
|
|
cursor.close()
|
|
connection.close()
|
|
|
|
except pyodbc.Error as ex:
|
|
print()
|
|
print("exception: ",ex)
|
|
cursor.close()
|
|
connection.close()
|
|
print()
|
|
exit()
|
|
|
|
print()
|