I'm scripting a chat program in python...
我正在用python编写一个聊天程序……
I'm on chatting program auth but don't know how to script authentication on python-mysql.
我正在使用聊天程序auth,但是不知道如何在python-mysql上编写脚本验证。
How can I authenticate with mysql using python?
如何使用python对mysql进行身份验证?
1 个解决方案
#1
3
import MySQLdb
dbHost = '127.0.0.1'
dbName = 'chat_db'
dbUser = 'username'
dbPass = 'passwd'
try:
db = MySQLdb.connect(host=dbHost, db=dbName, user=dbUser, passwd=dbPass)
except MySQLdb.MySQLError, err:
print "Cannot connect to database. MySQL error: " + str(err)
See mysql-python for doc & examples
有关doc和示例,请参阅mysql-python
#1
3
import MySQLdb
dbHost = '127.0.0.1'
dbName = 'chat_db'
dbUser = 'username'
dbPass = 'passwd'
try:
db = MySQLdb.connect(host=dbHost, db=dbName, user=dbUser, passwd=dbPass)
except MySQLdb.MySQLError, err:
print "Cannot connect to database. MySQL error: " + str(err)
See mysql-python for doc & examples
有关doc和示例,请参阅mysql-python