gpt4 book ai didi

python - 从客户端数据库中提取数据

转载 作者:太空宇宙 更新时间:2023-11-03 11:34:16 26 4
gpt4 key购买 nike

我必须通过 Python 将多个数据从客户端中分配的数据库发送到服务器中的主数据库,最好的解决方案是什么?我目前已经启动并运行我的网络服务器,我可以在本地填充我的数据库,但我真的不知道如何远程进行,我在我的硬件中使用 Python。

这是我目前在客户端中的内容:

import mysql.connector
cnx = mysql.connector.connect(user='user', password='pass', host='url?', database='db') #im able to enter with this
cursor = cnx.cursor()
query = ("INSERT INTO IGNORE table " "(id,date,son) " "VALUES( (%s,%s,%s)")
for row in data: #ive already extracted data from the other DB
cursor.execute(query, (row[0],row[1],row[2]))

产生错误:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IGNORE table(id,date,son) VALUES (number, '2017-11-09 14:33:15', 18.987)' at line 1

最佳答案

一种可能性 - 确保您的 mysqld 服务绑定(bind)到您的外部 ip 地址(在服务器上的 mysql 配置文件中设置)。默认情况下,我认为它绑定(bind)到 127.0.0.1 或本地主机。如果它绑定(bind)到本地主机,您的数据库将永远不会响应外部请求。

关于python - 从客户端数据库中提取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47188328/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com