- 论坛徽章:
- 0
|
更正下
楼上问的答案
def mysql_cursor():
global _conn
global _curs
if not _conn: # new connection on need
_conn = MySQLdb.connect (host = "localhost",
user = "root",
passwd = "Python123",
db = "ebooks")
_curs = None
mysql_commit() # save previous cursor
_curs = _conn.cursor() # new cursor
return _curs |
[ 本帖最后由 advancejar 于 2010-1-15 21:34 编辑 ] |
|