Python Forum
Create function around sql - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Create function around sql (/thread-24240.html)



Create function around sql - ayomayam - Feb-05-2020

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()


RE: Create function around sql - ayomayam - Feb-05-2020

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()