probcomp/BayesDB

Can't create a database from CSV

Closed this issue · 9 comments

I'm hitting errors working through the tutorial and can't create a new database from a CSV file. Here's my csv file, in the BayesDB VM home folder, called data.csv:

Week,New Users
1,1
2,7
3,15
4,1
5,4
6,4
7,20
8,39
9,213

And here's my Python script to create a database table from it:

from bayesdb.Client import Client
client = Client()

print client('CREATE BTABLE mytable FROM /home/bayesdb/data.csv')
print client('SELECT * FROM mytable')

Running the script, the output is:

bayesdb@bayesdb-v0:~$ python go.py
None
None
None
None

What's going wrong?

Thanks for the bug report! It looks like the VM currently on the website has an outdated (and broken) version of BayesDB. Sorry about that - we'll put a fixed VM up ASAP.

In the meantime, you can checkout and pull master for both ~/crosscat and ~/bayesdb to fix this.

$ cd ~/crosscat
$ git checkout master
$ git pull
$ cd ~/bayesdb
$ git checkout master
$ git pull

I have the same issue even after doing a pull on the master branch of both repos. I did notice theres a script (tests/scripts/dha_script.py) that uses client.execute() instead of just client(). Not sure which is right, neither seem to work correctly.

Does running

$ python ~/bayesdb/examples/dha/run_dha_example.py

Work for you?

Doesnt look like it. Below is the output I get, but its been running for a few minutes now but doesn't seem to be doing anything. Not sure its able to connect to the database?

output:

A series of BQL commands will be displayed. Hit to execute the displayed command.

DROP BTABLE dha_demo

Ah, this part is working. This is just a demo script, so it'll display a command, then execute it when you hit enter. Looks like that output has a typo - it was supposed to tell you to hit enter.

Hey I'm getting the same issue in the VM after pulling both repos. All the examples work fine, but just trying to create a simple database by following the docs (like @ollieglass tried above) does not seem to be working. It just returns None.

Try

from bayesdb.client import Client

bayesdb/Client.py got renamed to bayesdb/client.py. I'll update the docs accordingly. Does this fix your issue?

Oh, also: client() is just shorthand for client.execute().

And client.execute() defaults to printing out the results, and return None. You can play around with other arguments, such as client.execute(pretty=False), which returns the raw python object result without pretty-printing it.

Hey @jbaxter that did the trick for me (from bayesdb.client instead of from bayesdb.Client). Thanks for the quick response!