How to get SQRT in queries from existing queries (SQLite)


#1

Are there any ways to get SQRT in queries from existing queries?
It seems SQLite, which is used in queries from existing queries, doesn’t support SQRT and I found the extension at the bottom of this page (http://www.sqlite.org/contrib) might help, but I don’t know how to install it into Redash.
Or, are there any other ways?
I’m also hoping to use other math functions like STDEV, so maybe it’d be the best if I could install the math extension above.


#2

I resolved this by myself.
I compiled the C file as below (in case of Ubuntu)

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

and then added the following two lines in query_results.py

connection.enable_load_extension(True)
cursor.execute(‘select load_extension("/home/ubuntu/libsqlitefunctions.so");’)

Please let me know if there are better ways.