SQL connection method using pyodbc

How to get data with SQL and put it in dataframe


import pyodbc

cnxn = pyodbc.connect('DSN=hoge; UID=hoge; PWD=hoge')
cursor = cnxn.cursor()
cursor.execute(SELECT hogehoge FROM @hogehoge WHERE hogehoge)
rows= cursor.fetchall()
array_format = np.array(rows)
df1 = pd.DataFrame(array_format)

Recommended Posts

SQL connection method using pyodbc
Python-peewee connection method
Method call using __getattr__
Data visualization method using matplotlib (1)
Linear regression method using Numpy
Data visualization method using matplotlib (2)
Ssh connection using public key
Hachinai's grade management using SQL
Data visualization method using matplotlib (+ pandas) (5)
Parsing CSV format data using SQL
Noise removal method using wavelet transform
Data visualization method using matplotlib (+ pandas) (3)
Data visualization method using matplotlib (+ pandas) (4)