pymssql пример для MSSQL

python > pymssql пример для MSSQL
17.10.2019 10:04:13


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

[connect] [fetchone] [matplotlib] [pymssql] [server="skp-db2"] [user="user"] [password="password"] [database="db"] ['DRIVER=] [SERVER=skp-db2]


Статья:

import matplotlib.pyplot as plt
import numpy as np
import pyodbc
cnxn =  pymssql.connect(server="skp-db2", user="user", password="password", database="db")
#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()