Re: log() in sqlite3

Peng Yu <[email protected]>
Newsgroups gmane.comp.db.sqlite.general
Message-ID <CABrM6w=eMDgb4UFjE5YY=Tj3GzrJ_bKf+FVOQwu=nrp7Gjwm4w@mail.gmail.com>
How to use extension-functions.c? It means that I have to compile it?
How to use it with python?

For python, create_function should be a better solution? Thanks.

On 1/31/20, Chris Brody <[email protected]> wrote:
> The log function does seem to be supported by extension-functions.c which
> is available from here: https://www.sqlite.org/contrib
>
> On Fri, Jan 31, 2020 at 1:30 PM David Raymond <[email protected]>
> wrote:
>
>> 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
>>
> _______________________________________________
> sqlite-users mailing list
> [email protected]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>


-- 
Regards,
Peng
_______________________________________________
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.