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

'unix' connection parameter should allow path to directory of unix domain socket #70

Open
mrmilosz opened this issue May 17, 2014 · 3 comments

Comments

@mrmilosz
Copy link

For consistency with other libpq-based clients, py-postgresql should accept the path to the directory of a unix domain socket (e.g. '/var/run/postgresql') instead of the full path to the socket (e.g. '/var/run/postgresql/.s.PGSQL.5432'.) The 'port' connection parameter could be used to home in on the socket file itself (as is the behavior of the psql client.)

For backwards compatibility, the full path option should probably be left in. The program could attempt to parse the 'unix' parameter as a directory path and, on failure, attempt to parse it as a full path.

@jwp
Copy link
Contributor

jwp commented May 18, 2014

Agreed.

On Sat, May 17, 2014 at 12:40 AM, Milosz [email protected] wrote:

For consistency with other libpq-based clients, py-postgresql should
accept the path to the directory of a unix domain socket (e.g.
'/var/run/postgresql') instead of the full path to the socket (e.g.
'/var/run/postgresql/.s.PGSQL.5432'.) The 'port' connection parameter could
be used to home in on the socket file itself (as is the behavior of the
psql client.)

For backwards compatibility, the full path option should probably be left
in. The program could attempt to parse the 'unix' parameter as a directory
path and, on failure, attempt to parse it as a full path.

This issue came up in the following StackOverflow question:

http://stackoverflow.com/questions/23707988/psql-can-connect-to-a-unix-domain-socket-but-py-postgresql-with-the-same-parame


Reply to this email directly or view it on GitHubhttps://github.com//issues/70
.

@jwp
Copy link
Contributor

jwp commented Sep 6, 2016

To clarify why this hasn't been fixed yet. py-postgresql has to figure out where a given installation and/or database stores its file system sockets. We could scan a set of possibilities (assume) or use configuration files, or both. None of these seem desirable.

@mrmilosz
Copy link
Author

@jwp, to clarify, my suggestion is to pass in to py-postgresql the location of these file system sockets. As such, py-postgresql would have parameters socketDirectory and port and do something to the effect of:

socketPath = os.path.join(socketDirectory, '.s.PGSQL.%s' % port)

So, there is no need to scan a set of possibilities or use configuration files or anything like that.

This change would be predicated on the format of the socket filename itself being constant, which I believe to be true.

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