[GRASS-dev] How to calculate log() in v.db.update with SQLite backend?

Moritz Lennert mlennert at club.worldonline.be
Wed Nov 19 04:13:29 PST 2014


On 19/11/14 12:05, Markus Neteler wrote:
> On Wed, Nov 19, 2014 at 9:05 AM, Moritz Lennert
> <mlennert at club.worldonline.be> wrote:
>> Do you mean for your specific problem or generally in GRASS ?
>
> Ideally generally in GRASS.
>
>> I don't think
>> that we should start creating (and maintaining) our own version of functions
>> for specific backends. Users that need them should either use the options
>> provided by the backend, in this case the extension functions,
>
> Means
> - recompile SQLite locally, or

No, since version 3.6 you can compile the extension as a shared library 
and then activate it:

$ gcc -fPIC -lm -shared extension-functions.c -o libsqlitefunctions.so


$ sqlite3 test.db
SQLite version 3.8.7.1 2014-10-29 13:59:56
Enter ".help" for usage hints.
sqlite> create table test (value int);
sqlite> insert into test VALUES (1), (159), (257);
sqlite> select value, log(value) from test;
Error: no such function: log
sqlite> SELECT load_extension('/home/mlennert/SRC/libsqlitefunctions.so');

sqlite> select value, log(value) from test;1|0.0
159|5.06890420222023
257|5.54907608489522


> - add pysqlite support in GRASS GIS if it makes sense
> - ...
>
>> or should switch backends.
>
> So only the PG backend would do the job? Quite some effort to
> calculate a logarithm :-)
> Too bad that the SQLite backend doesn't come with the extended functions.

That's why it's called SQLite ;-)

Moritz


More information about the grass-dev mailing list