Answers for "how to import pyodbc in python"

SQL
3

pyodbc connect to sql server

import pyodbc 
# Some other example server values are
# server = 'localhostsqlexpress' # for a named instance
# server = 'myserver,port' # to specify an alternate port
server = 'tcp:myserver.database.windows.net' 
database = 'mydb' 
username = 'myusername' 
password = 'mypassword' 
cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER='+server+';DATABASE='+database+';UID='+username+';PWD='+ password)
cursor = cnxn.cursor()
Posted by: Guest on June-05-2020
0

using pypyodbc

conn = pypyodbc.connect("DRIVER={SQL Server};SERVER=MyServer;UID=me;PWD=password;DATABASE=db")
Posted by: Guest on October-23-2021

Code answers related to "SQL"

Browse Popular Code Answers by Language