Python-SQL连接到错误的ip地址

2024-06-25 23:49:53 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试使用一个简单的python脚本连接到我的sqlserver。在

import MySQLdb

db = MySQLdb.connect(host="192.168.0.156", user="root",
passwd="Imnottellingyoumypassword", db="mydatabase") # name of the data base

cur = db.cursor() 
cur.execute("SELECT * FROM customers")

for row in cur.fetchall() :
    print row[0]

但当我运行脚本时,出现了一些问题:

^{pr2}$

为什么他要连接到我笔记本电脑的ip地址而不是sql服务器?在


Tags: import脚本hostdbmyconnectrootdatabase