Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Create function around sql
#1
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()
Reply
#2
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()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Bug New to coding, Using the zip() function to create Diret and getting weird results Shagamatula 6 1,440 Apr-09-2023, 02:35 PM
Last Post: Shagamatula
  python create function validation mg24 1 833 Nov-15-2022, 01:57 AM
Last Post: deanhystad
  create my exception to my function korenron 2 788 Nov-09-2022, 01:50 PM
Last Post: korenron
  Create a function for writing to SQL data to csv mg24 4 1,152 Oct-01-2022, 04:30 AM
Last Post: mg24
  Create SQL connection function and validate mg24 1 938 Sep-30-2022, 07:45 PM
Last Post: deanhystad
  How to define a function to create a resorted list? sparkt 6 2,817 Aug-08-2020, 04:10 PM
Last Post: sparkt
  How to make this function general to create binary numbers? (many nested for loops) dospina 4 4,409 Jun-24-2020, 04:05 AM
Last Post: deanhystad
  Tried to create a function in a Datacamp course - why a is not equal to x_copy? danlin123 1 1,735 Jun-21-2020, 09:40 PM
Last Post: jefsummers
  create function let_to_num() al_Czervik 2 2,116 Apr-17-2020, 10:44 PM
Last Post: al_Czervik
  Create a function to find words of certain length ag4g 2 4,067 Apr-21-2019, 06:20 PM
Last Post: BillMcEnaney

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020