Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow unix socket connections with DB-API #52

Open
avbidder opened this issue Jan 7, 2011 · 4 comments
Open

Allow unix socket connections with DB-API #52

avbidder opened this issue Jan 7, 2011 · 4 comments

Comments

@avbidder
Copy link

avbidder commented Jan 7, 2011

c = dbapi20.connect(unix='/var/run/postgresql/.s.PGSQL.5432', database='msgid-test')

tells me that "host" and "unix" conflict. But I didn't give a "host" at all.

Additionally: it should be possible to connect to the default location for the unix socket

Additionally: the parameters to connect() are database specific according to the DB-API PEP, but connect() doesn't even have a docstring. Yes, it is "obvious" that connect() internally uses the same stuff as the PQ-API connect methods. Except that it's not obvious and (see above) the options are somehow modified before they're passed on.

(and yes, I want to use DB-API as far as I can.)

@jwp
Copy link
Contributor

jwp commented Jan 7, 2011

Thank you very much for the report. I'll look into this soon.

AFA default location and unix socket is concerned, it's a little difficult considering that the socket directory is configurable and subject to the installation of PostgreSQL. For libpq based drivers, it's no problem because it's part of the postgresql install and therefore it knows where to look. py-postgresql has no knowledge of where PG keeps its file system sockets.

@avbidder
Copy link
Author

avbidder commented Jan 7, 2011

Ok, I missed that py-postgresql doesn't use libpq.

Maybe for convenience have a list of frequently used locations (Debian / RedHat / SuSE / Solaris / ...) and try to use them.

Or: if unix domain socket is requested, the server is installed on the same machine anyway, maybe there's some way to find the socket? But I appreciate that this part of the request is not easy.

@jwp
Copy link
Contributor

jwp commented Aug 10, 2012

Just bumping this issue noting that I haven't forgotten about it.

@jwp
Copy link
Contributor

jwp commented Aug 3, 2018

Setting the host and port keywords to None is a workaround for this. The issue comes from the default parameters being built presume host localhost and port 5432. Additionally, dbapi20.driver.connect can be used directly to avoid the defaults altogether.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants