Skip to content

Commit 1ee9a1c

Browse files
Convert src/bqlfn.py from sqlite3 to apsw.
Bonus: apsw will now pass through exceptions raised by user-defined SQL functions, so no need for the stupid kludge to print them to stderr! (Github issue #15)
1 parent 4a128b5 commit 1ee9a1c

File tree

1 file changed

+1
-13
lines changed

1 file changed

+1
-13
lines changed

src/bqlfn.py

+1-13
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@
3131

3232
def bayesdb_install_bql(db, cookie):
3333
def function(name, nargs, fn):
34-
db.create_function(name, nargs,
35-
lambda *args: bayesdb_bql(fn, cookie, *args))
34+
db.createscalarfunction(name, (lambda *args: fn(cookie, *args)), nargs)
3635
function("bql_column_correlation", 3, bql_column_correlation)
3736
function("bql_column_correlation_pvalue", 3, bql_column_correlation_pvalue)
3837
function("bql_column_dependence_probability", 4,
@@ -45,17 +44,6 @@ def function(name, nargs, fn):
4544
function("bql_predict", 5, bql_predict)
4645
function("bql_predict_confidence", 4, bql_predict_confidence)
4746
function("bql_json_get", 2, bql_json_get)
48-
49-
# XXX XXX XXX Temporary debugging kludge!
50-
import sys
51-
import traceback
52-
53-
def bayesdb_bql(fn, cookie, *args):
54-
try:
55-
return fn(cookie, *args)
56-
except Exception as e:
57-
print >>sys.stderr, traceback.format_exc()
58-
raise e
5947

6048
### BayesDB column functions
6149

0 commit comments

Comments
 (0)