0
Ich versuche, die folgende Operation zu tun:Python/Pandas/PyMySQL -% s Synthax
import pymsql
import pandas as pd
df:
id height_code name ...
1 34 123123 Jesus
2 84 3421 Heaps
3 23 45243 Ornitorrincus
...
connection=pymysql.connect(host=xxx,user=xxxx,password=xxxx,db=xxxx)
for i in df.index:
df2=pd.read_sql("select business_id,name,color from table123 where business_id=%s;",connection) % df['id'][i]
Die Idee hier ist nur eine riesige SQL zugreifen und filtern table123 nur die Zeilen mit dem business_id = df['id'][i]
Allerdings erhalte ich folgende Fehlermeldung:
pandas.io.sql.DatabaseError: Execution failed on sql 'select business_id,nome,qualificacao_id from socio_administrador where business_id=%s;': (1064, "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 '%s' at line 1")
Also, anscheinend ich habe Probleme mit dem %s
Synthax in pymsql. Versucht, sich ihr Handbuch anzusehen, fand aber keine nette Erklärung dazu.
Kann jemand helfen?