_ | 覦覈襦 | 豕蠏手 | 殊螳 | 譯殊碁
FrontPage › Pyodbc

Contents

1 anaconda pyodbc install
2 pyodbc: 蠏谿 覯
3 pandas 伎


1 anaconda pyodbc install #

conda install -c anaconda pyodbc=3.0.10

2 pyodbc: 蠏谿 覯 #

Windows OS ODBC誤 讌 . 蠏碁 蟯 り 螳覃 蟆.
import pyodbc
conn = pyodbc.connect(driver='{SQL Server}', host='localhost,1433', database='pubs', user='id', password='pass')
#ODBC 誤  朱 れ螻 螳
#conn = pyodbc.connect('DSN=dbserver01')
cursor = conn.cursor()
cursor.execute("""
    select  
        type
    ,   count(*) cnt
    from dbo.titles
    group by
        type
    order by 2 desc
""")
rows = cursor.fetchall()
for row in rows:
    print (row.type, row.cnt)

3 pandas 伎 #

import pandas.io.sql as sql
import pyodbc
conn = pyodbc.connect(driver='{SQL Server}', host='localhost,1433', database='pubs', user='id', password='pass')

rows = sql.read_sql("""
    select  
        type
    ,   count(*) cnt
    from dbo.titles
    group by
        type
    order by 2 desc
"""
, conn)
print (rows)
蠍 蠍郁鍵..
企: : るジ讓曙 襦螻豺 企Ν 譯殊語. 襦螻豺
EditText : Print : Mobile : FindPage : DeletePage : LikePages : Powered by MoniWiki : Last modified 2019-04-11 16:06:22

螻螳 るゴり り 蠎蠍一 企ゴ讌 覈詩 朱 朱 豺谿 襷 殊瑚. 蠍一 朱 覲願 螻襷ろ 殊 覃伎 貉るる 殊 蠏碁る蓋る 蟆 蠏譴 殊企. (碁れ拘)