Answer the question
In order to leave comments, you need to log in
How to pass function parameter to sql query?
There is a function from x[0] and x[1].
How to pass the function parameters x[0] and x[1] to the sql query so that it has a different parameter each time, depending on the passed x[0] and x[1]?
For example, I want the sql-query parameter ph.riverplayeractiontype_id between x[0] and x[1] to be different depending on the passed x[0] and x[1], at the moment there are just numbers.
If I write x directly in the request instead of a number, then naturally I write a request error, but I can’t guess how to do it correctly.
Thanks in advance.
def po_function(x):
import psycopg2 as p
con = p.connect("dbname='dbase' user='postgres' host='localhost'")
cur = con.cursor()
cur.execute(
"select ph.handtimestamp,ph.netamountwon,ph.maxstreetseen,ph.player_id,(select sklanskybucks from allinsituations ais where ais.playerhand_id = ph.playerhand_id) as sklanskybucks,gt.currency_id from playerhandscashkeycolumns ph join gametypes gt on gt.gametype_id = ph.gametype_id left join playerhandsflop flop on ph.playerhand_id = flop.PLayerHand_id where ph.player_id = 39 and (ph.gametype_id = 1 or ph.gametype_id = 2 ) and ph.didpfr =true and flop.lasttoactonstreet =true and ph.riverplayeractiontype_id between 23 and 44 and gt.game = 1 order by ph.handtimestamp asc"
)
vsepolia = cur.fetchall()
return len(vsepolia)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question