1

I am new to PostgreSQL and odo. I've created the following: (I am working on Ubuntu).

I've created superuser testuser and with this user (role) I've created postgresql database testuser (by running psql and then CREATE DATABASE testuser;). In this database is a table called testtable. I have no troubles inserting into this database with psycopg2. But I've come across the odo module for python. Since my goal is to load some_file.csv into the postgresql database I thought I would use it. The usage seemed rather straightforward

import odo
odo.odo('some_file.csv', 'postgresql://testuser:<password>@127.0.0.1:5432/testuser::testtable')

But it does not work, and I get

NotImplementedError: Unable to parse uri to data resource: postgresql://testuser:<password>@localhost:5432/testuser 

Note: instead <password> I have the testuser's password.

Maybe it is obvious and I have to implement it.. (as in the last paragraph here), but I thought postgresql is supported (because postgresql is mentioned few times there, with examples). I've tried to look here under Connection URIs, but could not find a mistake. And here is odo documentation.

2
  • Are you trying to insert a CSV file as a single data blob or into a structured table (or multiple tables). Do you understand the basics of RDBMS, do you know the table structure? Do you know the structure of your CSV data (if any)? Commented Mar 26, 2016 at 19:50
  • Yes, I am trying to insert it in a single step into single table(at least start at that, as I assume that's the basic step). I read somewhere, that odo uses COPY command for that. I've created the table, e.g like this "CREATE TABLE testtable(id serial PRIMARY KEY, age integer, name varchar);" and the testing csv looks like this "25, John\n34, Petr",\n represents new line. Commented Mar 26, 2016 at 19:54

1 Answer 1

2

I have used odo to insert a csv file into postgresql, so it is supported. Your connection URI and code are essentially the same as mine. Do you have the sqlalchemy package installed? I believe odo uses both sqlalchemy and psycopg2 in the background. I was able to replicate your error on a system without sqlalchemy installed, and installing sqlalchemy got me past the error.

Sign up to request clarification or add additional context in comments.

4 Comments

That might really be it. I did not install sqlalchemy.. I thought I would get the standard import missing error. I'll try that! Thanks
I found a similar issue on github with the same resolution. It's not specifically related to postgres, but I imagine that the underlying code traces back to the same source for most databases that are implemented.
Ok, thanks. By the way, don't you know, whether conversion from xls->csv works? I don't have it in front of me, but I think i got similar error with odo('<abs_path_to_my.xls>', 'my.csv'). I feel dumb, since odo seems really easy to use, or is it too good to be true?
I get a similar NotImplementedError trying to convert an xls file, but according to github it's actually not implemented in this case, as opposed to just being due to missing packages.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.