---
title: "mysql-python 异常"
author: "baitian"
date: "2008-08-29T18:18:15Z"
tags: []
slug: "mysql-python"
draft: false
lastmod: "2008-08-29T18:18:15Z"
id: 234563
url: "https://baitian.iteye.com/blog/234563"
---

centos5
python2.5.2
mysql-python1.2.2

```python

import MySQLdb
import sys
db=MySQLdb.connect(user="##",passwd="##",db="##",host="######",port=3306)
cur=db.cursor(MySQLdb.cursors.Cursor)
sql="show tables"
cur.execute(sql)
```


执行到最后一句时，抛出异常了：
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "MySQLdb/cursors.py", line 166, in execute
    self.errorhandler(self, exc, value)
  File "MySQLdb/connections.py", line 35, in defaulterrorhandler
    raise errorclass, errorvalue
SystemError: NULL object passed to Py_BuildValue


找了一天，发现这方面的资料几乎没有，不知道有人碰到过这样的情况没？