Ooups !

Thanks to the awesome  posts about "RPAD/LPAD", I understood that I could
already create a "sqrt()" function for SQLite3  in interpreted python.

**** (example) *******
import sqlite3
db_filename = ':memory:'

def mysqrt(s):
    """ returns sqrt(s)"""
    #must return a string, apparently
    return ("%s" %sqrt(s))

with sqlite3.connect(db_filename) as conn:

    conn.create_function('mysqrt', 1, mysqrt)
    cursor = conn.cursor()
    query = "select 'hello, sqrt' , mysqrt(3), 'of ', mysqrt(3)*mysqrt(3) "
    cursor.execute(query)
    for row in cursor.fetchall():
        print (row)
    cursor.close
    cursor = None
conn.close
conn = None


**** (The link that showed nicely how to play with that) *******
http://pymotw.com/2/sqlite3/
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to