Forums

Error when using sqlite3

When I try to use this command in pythonanywhere (I want to do a running sum of the number of mentions):

db.execute("SELECT ticker, date_updated, SUM(mentions) OVER (ROWS UNBOUNDED PRECEDING) AS mentions FROM wsb_trending_24H where ticker=?", (ticker, ))

sqlite3.OperationalError: near "(": syntax error is raised.

But I have no issue with that command in my local Windows 10 computer. Could it be a different in sqlite version, and if so, what are the solution to it? Thanks

Yes, I think it's a SQLite version problem -- the "select ... over" syntax is a window function, and you need a recent version of SQLite to support those. Your account is set up to use our "fishnchips" system image (essentially, the version of the operating system your code runs under), and that has an older version of SQLite. Our most recent system image, "glastonbury", has a more recent version of SQLite that does support window functions.

You can switch the system image over to the more recent one by following the instructions on this help page, but do be aware that you might need to modify your existing code or rebuild virtualenvs to make sure that everything is compatible with all of the upgraded system files -- there's more information about that on the help page.

it works! Thank you!

Excellent! Thanks for confirming that.