Re: log() in sqlite3

David Raymond <[email protected]>
Newsgroups gmane.comp.db.sqlite.general
Message-ID <VI1PR07MB60299310587C6B182D2FF91A87070@VI1PR07MB6029.eurprd07.prod.outlook.com>
The core functions of the library are fairly unlikely to get expanded upon at this point, so it's up to the application using the SQLite library to expand on them.

You can load an extension which has those functions. Or the C API gives you means to add your own functions.

For Python, the built in sqlite3 module has the create_function() method for a connection which will register a function.
https://docs.python.org/3.8/library/sqlite3.html#sqlite3.Connection.create_function

Once you register the function you can use it right in your sql text like any other function,
"update tbl set field2 = log(field1);"

And you don't need to do the more tedious:
a) Get original data with statement 1
b) Do calculations in the outside program
c) Use the result in statement 2


-----Original Message-----
From: sqlite-users <[email protected]> On Behalf Of Peng Yu
Sent: Friday, January 31, 2020 12:42 PM
To: SQLite mailing list <[email protected]>
Subject: [sqlite] log() in sqlite3

Hi,

I see that many math functions (like log()) are not in sqlite3. It
seems that SQL standard doesn't have them.

https://www.sqlite.org/lang_corefunc.html

But since sqlite3 contains non-standard functions anyway. Would it be
considered to add those functions?

Given the current version of sqlite3, is the only choice of computing
log() to get the data into another language (e.g., python) and compute
the log over there? Thanks.

-- 
Regards,
Peng
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.