| « | Ò»ÔÂ 2009 | » | ||||
|---|---|---|---|---|---|---|
| Ò» | ¶þ | Èý | ËÄ | Îå | Áù | ÈÕ |
| 1 | 2 | 3 | 4 | |||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| 12 | 13 | 14 | 15 | 16 | 17 | 18 |
| 19 | 20 | 21 | 22 | 23 | 24 | 25 |
| 26 | 27 | 28 | 29 | 30 | 31 | |
1. °²×°activepython
2. °²×°ez_install
3. ÏÂÔØ mysqldb È»ºó ²âÊÔ
import MySQLdb Çø±ð´óСд£¬Ã»Óб¨´í¾ÍÊǶԵġ£
3. ÏÂÔØ formencode.egg È»ºó python easy_install formencode.egg
4. ÏÂÔØ sqlobject.egg È»ºó python easy_install sqlobject.egg
import sqlobject Çø±ð´óСд£¬Ã»Óб¨´í¾ÍÊǶԵġ£
1¡£mysqlÏêϸ²âÊÔ
def viewmysql():
# import MySQL module
import MySQLdb
db = MySQLdb.connect(host="localhost", user="root", passwd="",db="test")
cursor = db.cursor()
cursor.execute("use phpmyadmin")
cursor.execute("select * from pma_column_info")
result = cursor.fetchall()
print result
viewmysql()
2¡£TroubleShooting
µÚ4²½×îΪΣÏÕ£¬ÎÒÔÙpythonwinÖÐÖ´ÐУ¬µÚ¶þ´ÎÖ´ÐÐʼÖÕÏÔʾµÄÊÇ
ValueError: class Person is already in the registry (other class is <class '__main__.Person'>, from the module __main__ in (unknown); attempted new class is <class '__main__.Person'>, from the module __main__ in (unknown))
¼òÖ±¿´²»¶®£¬ÓÐЩÏóÊÇ×îÔçʹÓÃjavaµÃnullpointexception ,Ò»²ã²ãµÄ¶ÑջǶÌ×£¬ÕæµÄÒª°ÑÈËÏÅÍ˵ġ£