Help: Pass Python parameter into Cypher statement syntax

So I have a working Cypher query within python which can query my Neo4j database and return a result when a property key value is hardcoded. It looks like this:

piq = """MATCH (p:Person {bid: '123456789'}), blah blah blah """
with driver.session() as session:
profile_info = session.run(piq).values()

What I want to do is replace that string value with a parameter:
bid = 123456789
so the query text becomes something like
piq = """MATCH (p:Person {bid: bid}), blah blah blah """

I have tried $bid, {bid}, and also specifying things in the session.run area but just can't seem to find the correct syntax.

Any help, would be appreciated, and I would rather not try to install py2neo as I have had enough of the driver conflicts.

Hello @FourMoBro :slight_smile:

with ctx.session() as ses:
    profile_info = ses.run("MATCH (p:Person {bid: $bid}), blah blah blah ", bid=bid)

Regards,
Cobra

Thanks @cobra. I was close, but I also had another error in my code.
I also needed to have bid=str(123456789)

I love how fast this community responds!

1 Like

Oh yeah sorry, I didn't see it was a string :slight_smile: