Use the Python action Access database

xiaoxiao2021-03-06  109

Python Operation Access Database

First download Win32all at http://starship.python.net/crew/mhammond/win32/downloads.html

Then install it, below is an example;

Import win32com.client

Objconn = Win32com.client.dispatch (R'adodb.connection ")

# Connstr = "provider = sqloledb; data source = EL_SERVIDOR; Initial Catalog = base_de_datos; user ID = USuario; Password = contrase? a;"

Connstr = r "provider = microsoft.jet.Oledb.4.0; data source = db2.mdb"

Objconn.open (Conntr)

Objrs = Win32com.client.dispatch (R'adodb.Recordset ')

SQLQuery = "SELECT * from IPMAC"

# Everything is like ADO

Objrs.open (SqlQuery, Objconn, 1, 3)

While NOT ObJRS.EOF:

Print Objrs ("IP")

Objrs.movenext ()

Objrs.close ()

Objrs = none

Objconn.close ()

Objconn = none

Speed ​​is also good

转载请注明原文地址:https://www.9cbs.com/read-104139.html

New Post(0)