Python Read Access Database

zhaozj2021-02-16  50

Python read Access MDB files

--------------------------------- Import win32com.clientconn = Win32com.client.dispatch (R'adodb.connection " DSN = 'provider = microsoft.jet.OLDB.4.0; Data Source = E: /DB1.MDB;' Conn.Open (DSN) RS = Win32com.client.dispatch (R'adodb.Recordset ') rs_name =' co 'Rs.open (' [' rs_name '] ', conn, 1, 2) # How is the value of parameters 1, 2 in this function, I still don't know, still try. FLDS_DICT = {} for x in}: flds_dict [x] = rs.fields.Item (x) .namex = rs.fields.item (1) .valueprint x # conn.close () - ------------------------------------------- The above code is completely correct, but why Is it also the following mistakes? The reason I found out because the value in the table of the database is Chinese, so the following error occurs, change to English. I want to ask everyone how to use, Chinese content, or Chinese table name. Thank you.

Traceback (most recent call last): File "D: /PYTHON23/lib/site-packages/Pythonwin/pywin/framework/scriptutils.py", line 310, in RunScript exec codeObject in __main __.__ dict__ File "D: / Python23 / Src / script1.py ", line 12, in? print x file" d :/python23/lib/site-packages/pythonwin/pywin/framework/winout.py ", line 172, in Write Return Self.Template.write ( MSG) File "D: /Python23/Lib/site-packages/python/pywin/framework/winout.py", line 487, in Write Self.Handleoutput (Message) file "D: / Python23 / LIB / Site-packages / Pythonwin / pywin / framework / winout.py ", line 468, in handleoutput self.queueflush () file" d: /python23/lib/site-packages/pythonwin/pywin/framework/winout.py ", Line 444, In Queueflush Item = str (item) UnicodeEncodeError: 'ascii' codec can't Encode Characters in position 0-3: Ordinal Not in Range (128) >>> This is an article that has no result, I am also trying to find this result. The code is almost all from 9CBS and foreign websites. There are still many don't understand, and the netizens in the mail list on Python.cn gave me a lot of help. WiDE288 2004-1-18

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

New Post(0)