This project is archived and is in readonly mode.

#185 ✓invalid
Psycopg website

connect doesn't support connection URIs

Reported by Psycopg website | October 14th, 2013 @ 08:52 PM

Submitted by: Joe F

According to the documentation for connect:

The connection parameters can be
specified as a libpq connection string using the dsn parameter

However, passing in a connection URL fails with an error:

psycopg2.OperationalError: missing "=" after "postgresql://postgres@localhost:2345/test" in connection info string

According to the DBI 2.0 spec, connection parameters are db specific, and the URI form is definitely allowed by libpq:

http://www.postgresql.org/docs/current/static/libpq-connect.html#LI...

Using a URI is advantageous because it allows the db (and parameters) to be specified in one config variable or command line arg instead of spread across many. It's also more compatible with other runtimes thus allowing the same enviroment variable to be used for, say, a c program, a java program and a python script.

Comments and changes to this ticket

  • Daniele Varrazzo

    Daniele Varrazzo October 15th, 2013 @ 10:07 AM

    • State changed from “new” to “invalid”

    Psycopg doesn't parse the connection string: it is passed verbatim to the libpq.

    In [3]: psycopg2.connect("postgresql://postgres@localhost:5432/test")
    Out[3]: <connection object at 0x178fbc0; dsn: 'postgresql://postgres@localhost:5432/test', closed: 0>
    

    you have an older libpq on your client, one that doesn't support the URI syntax yet.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

<b>WARNING:</b> the informations in this tracker are archived. Please submit new tickets or comments to <a href="https://github.com/psycopg/psycopg2/issues">the new tracker</a>.
<br/>
Psycopg is the most used PostgreSQL adapter for the Python programming language. At the core it fully implements the Python DB API 2.0 specifications. Several extensions allow access to many of the features offered by PostgreSQL.

Shared Ticket Bins

Pages