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

Moritz Lennert mlennert at club.worldonline.be
Wed Nov 19 00:05:48 PST 2014


On 18/11/14 22:34, Markus Neteler wrote:
> Hi,
>
> playing around with the "Meuse" dataset about soil contamination I
> attempted to calculate that right away but...:
>
> v.db.update meuse_voronoi column="logzinc" qcolumn="log(zinc)"
> DBMI-SQLite driver error:
> Error in sqlite3_prepare():
> no such function: log
>
> DBMI-SQLite driver error:
> Error in sqlite3_prepare():
> no such function: log
>
> ERROR: Error while executing: 'UPDATE meuse_voronoi SET logzinc=log(zinc)'
>
> After some online research I found that I would need to tune my local
> SQLite installation with
>
> https://sqlite.org/contrib/download/extension-functions.c
> "extension-functions.c (50.96 KB) contributed by Liam Healy on
> 2010-02-06 15:45:07
> Provide mathematical and string extension functions for SQL queries
> using the loadable extensions mechanism. Math: acos, asin, atan, atn2,
> atan2, acosh, asinh, atanh, difference, degrees, radians, cos, sin,
> tan, cot, cosh, sinh, tanh, coth, exp, log, log10, power, sign, sqrt,
> square, ceil, floor, pi. String: replicate, charindex, leftstr,
> rightstr, ltrim, rtrim, trim, replace, reverse, proper, padl, padr,
> padc, strfilter. Aggregate: stdev, variance, mode, median,
> lower_quartile, upper_quartile.
> "
>
> Alternative: use pysqlite and define an own function.
>
> Which way to go?

Do you mean for your specific problem or 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, or should switch backends.

Moritz


More information about the grass-dev mailing list