Skip to content

Commit

Permalink
1. Fix sqlite datetime in sql
Browse files Browse the repository at this point in the history
2. Fix use pandas fillna to avoid NaNs
  • Loading branch information
salivian committed Nov 12, 2019
1 parent 326255b commit 300ff13
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
10 changes: 6 additions & 4 deletions web/bin/db_rest_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,17 @@ def data():
q = request.form['q']
format = request.form['format']
resp = make_response()
print(q)

data=pd.read_sql(q,engine).fillna(None)
mime

data=''
mime=''
if format=='json':
data = json.dumps(pd.read_sql(q,engine).to_dict(orient='records'))
data = json.dumps(data.to_dict(orient='records'))
mime = 'text/json'

if format=='csv':
data = pd.read_sql(q,engine).to_csv(index=False)
data = data.to_csv(index=False)
mime = 'text/csv'

resp.data=data
Expand Down
2 changes: 1 addition & 1 deletion web/dist/index.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<!DOCTYPE html><html><head><meta name="viewport" content="initial-scale=1,maximum-scale=1,
user-scalable=no"><link rel="stylesheet" href="web.416d5ffe.css"></head><body> <div id="nc"></div> </body><script src="web.7f0fc0fb.js"></script></html>
user-scalable=no"><link rel="stylesheet" href="web.416d5ffe.css"></head><body> <div id="nc"></div> </body><script src="web.44b709ef.js"></script></html>
4 changes: 2 additions & 2 deletions web/dist/web.7f0fc0fb.js → web/dist/web.44b709ef.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions web/dist/web.44b709ef.js.map

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion web/dist/web.7f0fc0fb.js.map

This file was deleted.

5 changes: 4 additions & 1 deletion web/src/Nanocube/Viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ let Viewer = function(opts){

let resp=await fetch(url, {method:'POST',
body: formdata});

console.log('sql ',sql);

if(format == 'json'){
return await resp.json();
}
Expand Down Expand Up @@ -471,7 +474,7 @@ Viewer.prototype = {
}
}
if(c[k].type=='time'){
return sprintf('("%s" BETWEEN \'%s\' AND \'%s\')',k,
return sprintf('("%s" BETWEEN datetime("%s") AND datetime("%s"))',k,
c[k].sel.start.toISOString(),
c[k].sel.end.toISOString());
}
Expand Down

0 comments on commit 300ff13

Please sign in to comment.