{"action":"closed","issue":{"url":"https://api.github.com/repos/mfenniak/pg8000/issues/125","repository_url":"https://api.github.com/repos/mfenniak/pg8000","labels_url":"https://api.github.com/repos/mfenniak/pg8000/issues/125/labels{/name}","comments_url":"https://api.github.com/repos/mfenniak/pg8000/issues/125/comments","events_url":"https://api.github.com/repos/mfenniak/pg8000/issues/125/events","html_url":"https://github.com/mfenniak/pg8000/issues/125","id":196511657,"number":125,"title":"Connecting via default unix socket without username/password","user":{"login":"phdru","id":730158,"avatar_url":"https://avatars.githubusercontent.com/u/730158?v=3","gravatar_id":"","url":"https://api.github.com/users/phdru","html_url":"https://github.com/phdru","followers_url":"https://api.github.com/users/phdru/followers","following_url":"https://api.github.com/users/phdru/following{/other_user}","gists_url":"https://api.github.com/users/phdru/gists{/gist_id}","starred_url":"https://api.github.com/users/phdru/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phdru/subscriptions","organizations_url":"https://api.github.com/users/phdru/orgs","repos_url":"https://api.github.com/users/phdru/repos","events_url":"https://api.github.com/users/phdru/events{/privacy}","received_events_url":"https://api.github.com/users/phdru/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-12-19T20:23:28Z","updated_at":"2016-12-28T21:07:08Z","closed_at":"2016-12-28T21:07:08Z","body":"Hello! I have the following settings in my pg_hba.conf:\r\n\r\n```conf\r\nlocal   all             all                                     peer\r\nhost    all             all             127.0.0.1/32            md5\r\n```\r\n\r\nThat allows me to connect to any database via unix socket without authentication, but when I connect via `localhost` I am asked for password.\r\n\r\nI.e., I can run\r\n\r\n```shell\r\n$ createdb test\r\n$ psql test\r\nconnected\r\n```\r\n\r\nand be connected. Please note that by default `psql` (`libpq`, perhaps?) connects via unix socket; also note `psql` doesn't require username. If I want to connect via localhost I have to do it explicitly:\r\n\r\n```shell\r\n$ psql -h localhost test\r\nPassword:\r\n```\r\n\r\nI can also connect via non-standard unix socket, the option is also `-h host`:\r\n\r\n```shell\r\n$ psql -h /run/postgresql test\r\nconnected\r\n```\r\n\r\nOnly directory is required. Driver `psycopg2` follows the conventions (perhaps because they are imposed by `libpq` and `psycopg2` uses `libpq`):\r\n\r\n```python\r\ncon = psycopg2.connect(database=\"test\")  # connected\r\n```\r\n\r\n```python\r\ncon = psycopg2.connect(database=\"test\", host='/run/postgresql')  # connected\r\n```\r\n\r\nUnfortunately, pg8000 doesn't follow these conventions:\r\n\r\n```python\r\ncon = pg8000.connect(database=\"test\")\r\n\r\nTraceback (most recent call last):\r\n  File \"./test_pg8000.py\", line 7, in <module>\r\n    con = pg8000.connect(database=\"test\")\r\n  File \"/home/phd/.tox/SQLObject/py27-pg8000/local/lib/python2.7/site-packages/pg8000/__init__.py\", line 105, in connect\r\n    user, host, unix_sock, port, database, password, ssl, timeout)\r\n  File \"/home/phd/.tox/SQLObject/py27-pg8000/local/lib/python2.7/site-packages/pg8000/core.py\", line 1231, in __init__\r\n    \"The 'user' connection parameter cannot be None\")\r\npg8000.core.InterfaceError: The 'user' connection parameter cannot be None\r\n```\r\n\r\n```python\r\ncon = pg8000.connect(database=\"test\", user='')\r\n\r\nTraceback (most recent call last):\r\n  File \"./test_pg8000.py\", line 8, in <module>\r\n    con = pg8000.connect(database=\"test\", user='')\r\n  File \"/home/phd/.tox/SQLObject/py27-pg8000/local/lib/python2.7/site-packages/pg8000/__init__.py\", line 105, in connect\r\n    user, host, unix_sock, port, database, password, ssl, timeout)\r\n  File \"/home/phd/.tox/SQLObject/py27-pg8000/local/lib/python2.7/site-packages/pg8000/core.py\", line 1607, in __init__\r\n    raise e\r\npg8000.core.InterfaceError: md5 password authentication failed\r\n```\r\n\r\nSeems like I'm connecting via localhost, not unix socket.\r\n\r\n```python\r\ncon = pg8000.connect(database=\"test\", user='',\r\n                     unix_sock='/var/run/postgresql/.s.PGSQL.5432')\r\n\r\nTraceback (most recent call last):\r\n  File \"./test_pg8000.py\", line 10, in <module>\r\n    unix_sock='/var/run/postgresql/.s.PGSQL.5432')\r\n  File \"/home/phd/.tox/SQLObject/py27-pg8000/local/lib/python2.7/site-packages/pg8000/__init__.py\", line 105, in connect\r\n    user, host, unix_sock, port, database, password, ssl, timeout)\r\n  File \"/home/phd/.tox/SQLObject/py27-pg8000/local/lib/python2.7/site-packages/pg8000/core.py\", line 1607, in __init__\r\n    raise e\r\npg8000.core.InterfaceError: md5 password authentication failed\r\n```\r\n\r\nOuch! What is going on? What username must be passed?\r\n\r\nCan pg8000 be fixed so that\r\n\r\n```python\r\ncon = pg8000.connect(database=\"test\")\r\n```\r\n\r\nconnects via default unix socket, without username/password?"}}
{"actor":{"display_login":"phdru"}}