pyodbc пример с MSSQL

python > pyodbc пример с MSSQL
17.10.2019 9:57:42


Наиболее часто встречающиеся слова в статье:

[fetchone] [matplotlib] [connect] ['DRIVER=] [SERVER=skp-db2] [DATABASE=MDM_Light] [execute] ["select] [vdrRecordState] [idRecordState]


Статья:

import matplotlib.pyplot as plt
import numpy as np
import pyodbc
cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=skp-db2;DATABASE=MDM_Light;')
t=[0]*10
cursor = cnxn.cursor()
cursor.execute("select * from dbo.vdrRecordState (nolock) ")
row = cursor.fetchone()
i=1
while 1:
    row = cursor.fetchone()
    if not row:
        break
    t[i]=row.idRecordState
    i=i+1
 
plt.plot(t)
plt.ylabel('y')
plt.xlabel('x')
plt.show()