mirror of
https://github.com/Microsoft/sql-server-samples.git
synced 2025-12-08 14:58:54 +00:00
Added Jupyter Sample Script
This commit is contained in:
17
samples/tutorials/python/jupyter/sample_python_jupyter.py
Normal file
17
samples/tutorials/python/jupyter/sample_python_jupyter.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import pyodbc
|
||||||
|
server = 'myserver'
|
||||||
|
database = 'mydb'
|
||||||
|
username = 'myusername'
|
||||||
|
password = 'mypassword'
|
||||||
|
|
||||||
|
#Connection String
|
||||||
|
cnxn = pyodbc.connect('DRIVER={SQL Server Native Client 11.0};SERVER='+server+';DATABASE='+database+';UID='+username+';PWD='+ password)
|
||||||
|
cursor = cnxn.cursor()
|
||||||
|
|
||||||
|
#Sample select query
|
||||||
|
cursor.execute("SELECT @@version;")
|
||||||
|
row = cursor.fetchone()
|
||||||
|
while row:
|
||||||
|
print row[0]
|
||||||
|
row = cursor.fetchone()
|
||||||
|
|
||||||
Reference in New Issue
Block a user