python訪問access
1
'''
2
py 訪問 ACCESS
3
'''
4
import
win32com.client
5
import
urllib
6
import
time
7
![](http://static.javashuo.com/static/loading.gif)
8
(a,b)
=
urllib.urlretrieve(
'
http://chenluqq.googlepages.com/webmail_verification.mdb
'
)
9
print
a
10
time.sleep(
30
)
11
print
b
12
![](http://static.javashuo.com/static/loading.gif)
13
conn
=
win32com.client.Dispatch(r
'
ADODB.Connection
'
)
14
DSN
=
'
PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=%s;
'
%
(a)
15
conn.Open(DSN)
16
rs
=
win32com.client.Dispatch(r
'
ADODB.Recordset
'
)
17
rs_name
=
'
select * ,expire-date() as havedays from webmail_sohu_verification where serialno=\
'
6200002DAH0C65N8\
''
18
rs.Open(rs_name, conn,
1
,
3
)
19
'''
20
for x in range(rs.Fields.Count):
21
print rs.Fields.Item(x).Value
22
'''
23
![](http://static.javashuo.com/static/loading.gif)
24
serialno
=
rs.Fields.Item(
'
serialno
'
).Value
25
code
=
rs.Fields.Item(
'
code
'
).Value
26
remark
=
rs.Fields.Item(
'
remark
'
).Value
27
Pid
=
rs.Fields.Item(
'
Pid
'
).Value
28
expire
=
rs.Fields.Item(
'
expire
'
).Value
29
havedays
=
int(rs.Fields.Item(
'
havedays
'
).Value)
30
print
serialno,code,remark,Pid,expire,havedays
31
![](http://static.javashuo.com/static/loading.gif)
32
'''
33
print rs.Fields.Item(x).Name
34
print rs.Fields.Item(x).Value
35
print rs.Fields.Item(1).DefinedSize
36
'''
37
![](http://static.javashuo.com/static/loading.gif)
38
rs.close
39
conn.close
歡迎關注本站公眾號,獲取更多信息