wave
wave copied to clipboard
More docs on WaveDB
Discussed in https://github.com/h2oai/wave/discussions/1660
Originally posted by mtanco October 5, 2022 Hello! I used WaveDB for the first time yesterday, and am not a regular SQLite user. I was having really hard time figuring out what the index was for / doing on the connection line in our docs:
from h2o_wave import connect
db = connect()["somerandomtext"]
And just stumbled upon this comment in one of the examples: https://github.com/h2oai/wave/blob/23fb7ae5c102b509a416692883e5db34e804f134/py/examples/db.py#L25
It would be great to have that explained / details on the https://wave.h2o.ai/docs/wavedb/ page!
I second this. The docs for installing is limited at best and non existent for running in prod via docker.
Ok tested, on v1.0.0 this works:
go install github.com/h2oai/wave/cmd/wavedb@latest
Which means one can do:
docker run --rm -ti -v $HOME/.local/bin:/go/bin -v ./:/go/src -w /go/src --nam
e=wavedb -p10100:10100/tcp golang:1.20 go run github.com/h2oai/wave/cmd/wavedb@latest
Then https://wave.h2o.ai/docs/wavedb#from-curl documents the ws+json protocol very well.
@mturoci looks like h2o_wave.connect.exec() is a bog standard sqlite executor. While connect is executing .open --new example.db so that connect()['example'] opens the sqlite3 file named ./example.db and attaching to it. Effectively the same as:
# sqlite
sqlite> attach database 'example.db' as RelDb;
sqlite> .databases
wavedb: /db/wavedb.db
example: /db/example.db
# python + h2o_wave
from h2o_wave import connect
# Create a database connection
connection = connect(...)
connection['wavedb'].exec('SELECT name FROM sqlite_schema WHERE type ='table' AND name NOT LIKE 'sqlite_%';')
connection['example'].exec('SELECT name FROM sqlite_schema WHERE type ='table' AND name NOT LIKE 'sqlite_%';')