Answers for "How to pass a data frame as parameter to a SQL query in Python?"

0

How to pass a data frame as parameter to a SQL query in Python?

import pandas as pd

your_column = pd.Series([1,2,3,4,5,6,7,8,9])

query = "SELECT ValueDate, Value"\
        "FROM Table "\
        "WHERE [ID] in {}".format(tuple(your_column))

print(query)
# 'SELECT ValueDate, ValueFROM Table WHERE [ID] in (1, 2, 3, 4, 5, 6, 7, 8, 9)'
Posted by: Guest on March-18-2022

Code answers related to "How to pass a data frame as parameter to a SQL query in Python?"

Python Answers by Framework

Browse Popular Code Answers by Language