1. python如何连接有密码的Access数据库并且查询数据

importpyodbc
dbfile="db2.mdb"
try:
conn=pyodbc.connect('DRIVER={MicrosoftAccessDriver(*.mdb)};PWD=thepwd;DBQ='+dbfile)
cur=conn.cursor()
cur.execute("select*fromstandard")
printcur.fetchone()
printdir(cur)
exceptpyodbc.Error,e:
printe[1]
exceptpyodbc.ProgrammingError,e:
printe[1]

2. python 操作ACCESS数据库中 如何删除记录

3、增加字段:
CString
msql
=
"ALTER
TABLE
student
ADD
COLUMN
zian
char(30)";
mdatabase。ExecuteSQL(msql);。。添加名为3zizhuan的字段到名为5student的表中6。
4、新纪版录:
msqlstr
=
"INSERT
INTO
student
(学号,姓名,数学)
VALUES
('5014','jack','67')";
mdatabase。ExecuteSQL(msql);。。添加学号为权55071,姓名为4jack,数学为062的一i行记录
到表student中0。
0、删除:
CString
msql
=
“DELETE
FROM
student
WHERE
学号
=
'1012'”;
mdatabase。ExecuteSQL(msql);。。删除学号为48006的一d行记录。
w鼎ヲ∞ai蓿n′一h≈jn′一ul

3. python 怎么操作access数据库

#!/usr/bin/envpython
#-*-conding:utf-8-*-

importpypyodbc
if__name__=="__main__":

str='Driver={MicrosoftAccessDriver(*.mdb)};DBQ=E:\123.mdb'
conn=pypyodbc.win_connect_mdb(str)
#conn=pypyodbc.connect(str)
cur=conn.cursor()
cur.execute("SELECT*FROMcatalog")
forrowincur.fetchall():
forfieldinrow:
printfield,
print''
conn.commit()
cur.close()
conn.close()

4. python读取数据access出错

DSN
=
'PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA
SOURCE=D:\Data.mdb;'
把D:\Data.mdb改成d:\\Data.mdb就行了。
python里面\是个特殊的释放符号。
推荐在字符串版前面加上权r标志。标识字符串是原生态,里面的释放符号都是原始符号
;)
推荐这样写:
DSN
=
r'PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA
SOURCE=D:\Data.mdb;'

5. python连接access数据库问题

数据库能打开是什么意思。。。用什么打开的
你的ODBC设置好了吗。。。

6. 如何在Python 中导入access 数据

Python操作Access数据库步骤之1、建立数据库连接
import win32com.client
conn = win32com.client.Dispatch(r'ADODB.Connection')
DSN = 'PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=C:/MyDB.mdb;'
conn.Open(DSN)
Python操作Access数据库步骤之2、打开一个记录集
rs = win32com.client.Dispatch(r'ADODB.Recordset')
rs_name = 'MyRecordset'#表名
rs.Open('[' + rs_name + ']', conn, 1, 3)
Python操作Access数据库步骤之3、对记录集操作
rs.AddNew()
rs.Fields.Item(1).Value = 'data'
rs.Update()
Python操作Access数据库步骤之4、用SQL来插入或更新数据
conn = win32com.client.Dispatch(r'ADODB.Connection')
DSN = 'PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=C:/MyDB.mdb;'
sql_statement = "Insert INTO [Table_Name] ([Field_1],
[Field_2]) VALUES ('data1', 'data2')"
conn.Open(DSN)
conn.Execute(sql_statement)
conn.Close()

Python操作Access数据库步骤之5、遍历记录
rs.MoveFirst()
count = 0
while 1:
if rs.EOF:
break
else:
countcount = count + 1
rs.MoveNext()

注意:如果一个记录是空的,那么将指针移动到第一个记录将导致一个错误,因为此时recordcount是无效的。解决的方法是:打开一个记录集之前,先将Cursorlocation设置为3,然后再打开记录集,此时recordcount将是有效的。例如:
rs.Cursorlocation = 3 # don't use parenthesis here
rs.Open('Select * FROM [Table_Name]', conn) # be sure conn is open
rs.RecordCount # no parenthesis here either

7. Python_access

access( path, mode)

Use the real uid/gid to test for access to path. Note that most operations will use the effective uid/gid, therefore this routine can be used in a suid/sgid environment to test if the invoking user has the specified access to path. mode should be F_OK to test the existence of path, or it can be the inclusive OR of one or more of R_OK, W_OK, and X_OK to test permissions. Return True if access is allowed, False if not. See the Unix man page access(2) for more information. Availability: Macintosh, Unix, Windows.
Note: Using access() to check if a user is authorized to e.g. open a file before actually doing so using open() creates a security hole, because the user might exploit the short time interval between checking and opening the file to manipulate it.

Note: I/O operations may fail even when access() indicates that they would succeed, particularly for operations on network filesystems which may have permissions semantics beyond the usual POSIX permission-bit model.

可以看看帮助

8. 如何在Python 中导入access 数据

Python操作Access数据库步骤之1、建立数据库连接
import win32com.client
conn = win32com.client.Dispatch(r'ADODB.Connection')
DSN = 'PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=C:/MyDB.mdb;'
conn.Open(DSN)
Python操作Access数据库步骤之2、打开一个记录集
rs = win32com.client.Dispatch(r'ADODB.Recordset')
rs_name = 'MyRecordset'#表名
rs.Open('[' + rs_name + ']', conn, 1, 3)
Python操作Access数据库步骤之3、对记录集操作
rs.AddNew()
rs.Fields.Item(1).Value = 'data'

9. python怎么开发access操作

在EXCEL中执行的代码是VBA,也就也是VB的一个子集,宏也就也一段VB代码,python脚本好象不能在其中运行,但如果是可执行的程序可以利用VB代码调用