Skip to content

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

Description

@mrmilosz

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.

Activity

  1. jwp commented on May 18, 2014

    @jwp
    Contributor

    Agreed.

    On Sat, May 17, 2014 at 12:40 AM, Milosz notifications@github.com 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
    .

  2. jwp commented on Sep 6, 2016

    @jwp
    Contributor

    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.

  3. mrmilosz commented on Sep 18, 2016

    @mrmilosz
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions