If the following code it runs great. However, I want to be able to have the user be able to enter the DeptName in the where clause. I have tried several ways using v1 = input(“Enter DeptName:”) but nothing works, in the ways that I am trying.
Any ideas would be appreciated.
Thanks
import pyodbc
#v1 = input("Enter DeptName: ")
conn = pyodbc.connect("Driver={SQL Server Native Client 11.0};"
"Server=DESKTOP-MCd2;"
"Database=North2;"
"Trusted_Connection=yes;")
cursor = conn.cursor()
cursor. Execute("SELECT * FROM EmpDetails where DeptName = 'CCC'")
print('EmpId ' + 'DeptId ' + 'DeptName')
for row in cursor:
print('%r' % (row,))