starting on stored procedures, at video 29, into it 1 min 36 sec
This commit is contained in:
@@ -0,0 +1,22 @@
|
|||||||
|
import pyodbc
|
||||||
|
|
||||||
|
try:
|
||||||
|
connection = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER=.;DATABASE=SampleDB;Trusted_Connection=yes')
|
||||||
|
|
||||||
|
cursor = connection.cursor()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
cursor.close()
|
||||||
|
connection.close()
|
||||||
|
|
||||||
|
except pyodbc.Error as ex:
|
||||||
|
print()
|
||||||
|
print("exception: ",ex)
|
||||||
|
cursor.close()
|
||||||
|
connection.close()
|
||||||
|
print()
|
||||||
|
exit()
|
||||||
|
|
||||||
|
print()
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
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 procedure usp_cus_details (@cusID int, @out nvarchar(max) output)
|
||||||
|
as
|
||||||
|
select * from tblCustomers where id = @cusID
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
cursor.execute(sql_cmd)
|
||||||
|
connection.commit()
|
||||||
|
|
||||||
|
print("stored procedure successfully created")
|
||||||
|
|
||||||
|
cursor.close()
|
||||||
|
connection.close()
|
||||||
|
|
||||||
|
except pyodbc.Error as ex:
|
||||||
|
print()
|
||||||
|
print("exception: ",ex)
|
||||||
|
cursor.close()
|
||||||
|
connection.close()
|
||||||
|
print()
|
||||||
|
exit()
|
||||||
|
|
||||||
|
print()
|
||||||
Reference in New Issue
Block a user