Python使用ODBC

#!/usr/bin/python
# -*- coding: utf-8 -*-

import ceODBC
con=ceODBC.connect('driver=MySQL ODBC 5.1 Driver;server=127.0.0.1;port=3306;database=django;uid=sa;pwd=sa;')
cur=ceODBC.Cursor(con)
cur.execute("SELECT count(*) FROM djuser")
rows=cur.fetchall()

for row in rows:
    print(row[0])

Leave a Reply

Your email address will not be published. Required fields are marked *

*