<div dir="ltr">Dear list, dear Markus, <div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/9/26 Markus Neteler <span dir="ltr"><<a href="mailto:neteler@osgeo.org" target="_blank">neteler@osgeo.org</a>></span><br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>On Wed, Sep 25, 2013 at 11:42 AM, Enrico Gallo <<a href="mailto:enrico.gallo@gmail.com" target="_blank">enrico.gallo@gmail.com</a>> wrote:<br>
> Dear list,<br>
> I am struggling with the use of simple math functions in SQL expression,<br>
> using SQLIte and db.execute.<br>
> I am writing a script for multiplatform end-users, so nor compiling SQLite<br>
> math contrib library nor piping data to bc using command line seem to me<br>
> feasable solutions.<br>
><br>
> Do you have any suggestion?<br>
<br>
</div>Could you post an example?<br></blockquote><div><br><br></div><div>GRASS 6.4<br></div><div><div class="gmail_quote">from North Carolina data set</div><div class="gmail_quote">sqlite mapset<br><br>g.copy vect=railroads@PERMANENT,foo<br>
</div><div>

v.db.addcol map=foo columns="power double precision,distance double precision,level double precision"<br></div><div><br>v.db.update map=foo column=power value=80<br>v.db.update map=foo column=distance value=100<br>

<br></div>
<div>v.db.update map=foo column=level value=power-distance<br></div><div>#  OK<br></div><div><br>v.db.update map=foo column=level value=power-log10(distance)   <br>DBMI-SQLite driver error:<br>Error in sqlite3_prepare():<br>


no such function: log10<br>ERROR: Error while executing: 'UPDATE foo SET level=power-log10(distance)<br>'<br><br></div>same error for sqrt(), log(), etc <br><br></div><div>see also [1] (in Italian) with dbf driver; SQLite suggestion seems wrong<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

<div><br>
> Including SQLite math functions in the standard binary GRASS GIS<br>
> distribuition could be a long term solution? I think this is the choice<br>
> SpatialLite did since 2.3 version.<br>
<br>
</div>You mean<br>
<a href="http://www.gaia-gis.it/gaia-sins/spatialite-sql-3.0.0.html#math" target="_blank">http://www.gaia-gis.it/gaia-sins/spatialite-sql-3.0.0.html#math</a><br>
<br>
hence<br>
<a href="http://www.sqlite.org/contrib" target="_blank">http://www.sqlite.org/contrib</a><br>
--> "extension-functions.c (50.96 KB) contributed by Liam Healy on<br>
2010-02-06 15:45:07<br>
Provide mathematical and string extension functions for SQL queries<br>
using the loadable extensions mechanism. Math: acos, asin, atan, atn2,<br>
atan2, acosh, asinh, atanh, difference, degrees, radians, cos, sin,<br>
tan, cot, cosh, sinh, tanh, coth, exp, log, log10, power, sign, sqrt,<br>
square, ceil, floor, pi. String: replicate, charindex, leftstr,<br>
rightstr, ltrim, rtrim, trim, replace, reverse, proper, padl, padr,<br>
padc, strfilter. Aggregate: stdev, variance, mode, median,<br>
lower_quartile, upper_quartile.<br>
"<br>
<br>
If you refer to this file, then it is more related to (your) SQLite<br>
installation rather than GRASS itself since GRASS just calls SQLite.<br>
<br>
best,<br>
Markus<br>
</blockquote></div><br>It's exactly what I meant<br><br></div><div class="gmail_extra">So there is not a way to use this kind of funtions with vector attributes without<br>compile extra library and load it in SQLIte? <br>
</div><div class="gmail_extra">Any python workaround?<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">Users need to change database, switching to MySQL or PostgreSQL?<br><br><br>Many thanks,</div><div class="gmail_extra">
Enrico<br></div><div class="gmail_extra"><br><br>[1] <a href="http://listserv.unipr.it/pipermail/grass-italia/2012-April/005897.html">http://listserv.unipr.it/pipermail/grass-italia/2012-April/005897.html</a><br><br><br></div>
<div class="gmail_extra"><br></div></div></div>