Binding Variables To Sqlalchemy Query For Pandas.read_sql
Is it possible to bind variables to a SQLAlchemy query used in a Pandas.read_sql statement? Using %s in the WHERE clause does not work and the documentation for cx_Oracle states:
Solution 1:
As you can see here, cx_Oracle.paramstyle is named not format. According to PEP 249 you have to use the :name syntax for named paramstyle:
import pandas as pd
sql = '''
 SELECT *
 FROM DUAL
 WHERE GROUP_NAME = :name
'''
df = pd.read_sql(sql, params={'name': the_name_you_want})
Post a Comment for "Binding Variables To Sqlalchemy Query For Pandas.read_sql"