Sign up for Free !!
World's first open source developer community with
Ticketing System
Need some sudeo code to refer ....
Here is the below which usually i prefer to do it,
Step 1:
You need to install the pyodbc package which will be used to connect Python to SQL Server.
pip install pyodbc
Step 2:
Get your SQL Server below details to connect,
'Server=server_name;' 'Database=database_name;'
Here is the sample code to connect,
import pyodbc conn = pyodbc.connect('Driver={SQL Server};' 'Server=server_name;' 'Database=database_name;' 'Trusted_Connection=yes;') cursor = conn.cursor() cursor.execute('SELECT * FROM database_name.table') for row in cursor: print(row)
Please Login/Register to write your answer !!!
Here is the below which usually i prefer to do it,
Step 1:
You need to install the pyodbc package which will be used to connect Python to SQL Server.
Step 2:
Get your SQL Server below details to connect,
Here is the sample code to connect,