In FaunaDb Shell is working but not working in python api

Hi,
I am working on a date range query, in the FaunaDB shell the query is working, but the same query in python API not working, can help me to resolve the issue. For more information, I have attached the error message.

Shell Query
Map(
Paginate(
Range(
Match(Index(“apsec_start_range_users”), “tilak@email.com”),
ToTime(Date(“2020-07-14”)),
ToTime(Date(“2021-01-01”))
)
),
Lambda(
[“start”,“ref”],
Update(
Var(“ref”),
{data: {date:ToDate(Var(“start”))}}
)
)
)

Python Code
result = client.query(
q.map_(
q.paginate(
q.range(
q.match(
q.index(“apsec_start_range_users”), “tilak@email.com
),
q.to_time(q.date(“2020-07-14”)),
q.to_time(q.date(“2021-01-01”))
)
),
q.lambda_(
[“start”, “ref”],
q.update(
q.var(“ref”),
{“data”: {“date”: q.to_date(q.var(“start”))}}
)
)
)
)

Error Message

Thanks

Hi @tilakt and welcome!

May you give a try to this query?

result = client.query(
  q.map_(
    q.lambda_(["start", "ref"],q.update(q.var("ref"),{"data": {"date": q.to_date(q.var("start"))}})),
    q.paginate(q.range(q.match(q.index("apsec_start_range_users"), "tilak@email.com"),q.date("2020-07-14"),q.date("2021-01-01")))
  )
)

In Python, Map() is a bit tricky, since you have to switch position between Paginate() and Lambda().

More information here

Let me know if it works.

Luigi

Hi @Luigi_Servini

Thank you so much, It worked. :slight_smile: