Python Forum

Full Version: Create function around sql
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
iwant to pass the arguments for where clause in the below code as a argument (keyword/positional) through outside the code. how do i do this ?

from sqlalchemy import create_engine
engine = create_engine('sqlite://', echo=False)

df.to_sql('star', con=engine)

rs=engine.execute("""
WITH moon AS ( select
column1
, column2

from cig
where column1 <= 100)

""").fetchall()
I want to pass the values for where clause in the below code as a argument (keyword/positional) through outside the code. how do i do this ? How to create an function and pass various values ?

from sqlalchemy import create_engine
engine = create_engine('sqlite://', echo=False)

df.to_sql('star', con=engine)

rs=engine.execute("""
WITH moon AS ( select 
column1
, column2

from star 
 where column1 <= 100)

""").fetchall()