coleifer/sqlite-web

SQLite built-in math functions(such as ln()) is not supported?

Closed this issue · 1 comments

Hi, first of all.
Thanks for maintaining this wonderful open source project. It's helpful a lot.

Um... the problem I have is following:

In terminal, below query is okay.

SELECT ln(1 + change_in_price/close_price) 
FROM stock_price WHERE short_code='005930' 
AND base_date='2022-01-10'

image

But in sqlite-web it's not working saying no such function: ln
image

There is version difference in sqlite in terminal and sqlite web.
(is that causing problem...?)

I'm not sure why this happens.
Thanks for reading (this silly quesiton..)!

The sqlite shell by default may include additional extensions that are not present in the shared library used by Python. To ensure the math functions are present within sqlite-web, you have a few options:

  • Compile math extensions into a loadable extension and load it using sqlite_web -e /path/to/math.so
  • Compile sqlite3 with all math functions and install system-wide or statically-linked to pysqlite3

See Sqlite docs here: https://www.sqlite.org/lang_mathfunc.html