0

I have a problem where SQL query runs without error in database(using Db browser), but when I run it in my python program it gives me an error. The following is the query:

c.execute("SELECT Date, Details, SUM((Debit) - (Credit)) OVER (ORDER by Date ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS balance FROM maindata WHERE Details =?' ORDER BY Date", pg)

It gives me this error-:

sqlite3.OperationalError: near "(": syntax error

5
  • Have you tried this: stackoverflow.com/questions/30257826/… Commented Jun 6, 2020 at 9:56
  • 2
    WHERE Details =?' This symbol ' after the ? looks strange Commented Jun 6, 2020 at 10:20
  • Tried both above answers but still not solved, Thank you. Commented Jun 6, 2020 at 10:31
  • 1
    Remove ' charactet from SQL, Also check whether pg parameter is a tuple or a list, if none of them (but for example a number or a string), then use c.execute(".....", (pg,) ) Commented Jun 6, 2020 at 11:20
  • I tried the above method but still getting the same error, I tried writing the query in 4 lines and the error is coming in (pg, ) ) Commented Jun 7, 2020 at 11:18

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.