0

I am trying to pass a parameter to a pandas dataframe database query but I cant quite get the syntax right. What am I missing? This works for default python, not pandas and unfortunately the pandas docs dont help. I also tried googling the standard mentioned with no luck. My query works fine when I replace the %s with the actual category id

sqlQuery='''SELECT aa.*
    FROM ballot aa
    WHERE categoryId = %s
       '''
df1=pd.read_sql_query(sqlQuery,connectionObject,'529') #trying to pass in 529
Rilcon42
  • 9,584
  • 18
  • 83
  • 167

1 Answers1

0

I just format the string as I pass it to read_sql

df = pd.read_sql(sqlQuery % '529', connectionObject)
Sebastian
  • 1,623
  • 19
  • 23