DBA

python select query DataFrame 으로 보여주기 본문

[3] Development/Python

python select query DataFrame 으로 보여주기

코볼 2022. 4. 29. 14:30
728x90
반응형
SMALL
import pymssql
from pandas import DataFrame
cursor.execute("select * from TableName")

row = cursor.fetchall()
data_name = ["id", "name", "englishName", "teamID", "email"]

df = DataFrame(row, columns=data_name)

print(df)

 

 

 

pandas.read_sql() 사용

import pymssql
from pandas import *
conn = pymssql.connect(host="", port=, user="sa", password="", database="EXAMPLE", charset="utf8")
sql = "select id, name, englishName, teamID, email from TabelName"
df = pandas.read_sql(sql, conn)
print(df)
728x90
반응형
LIST
Comments