connecting to databases does not work

Bug #1182835 reported by Ulf Mehlig
32
This bug affects 6 people
Affects Status Importance Assigned to Milestone
py-postgresql (Ubuntu)
Fix Released
High
Unassigned

Bug Description

Connection attempts to databases on localhost and on remote hosts fail with the following error messages (user name, password and database name substituted by placeholders):

Python 3.3.1 (default, Apr 17 2013, 22:30:32)
[GCC 4.7.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import postgresql
>>> db = postgresql.open("pq://theusername:thepasswd@localhost/thedatabasename")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/postgresql/__init__.py", line 88, in open
    c.connect()
  File "/usr/lib/python3/dist-packages/postgresql/driver/pq3.py", line 2559, in connect
    sd = self.sys.startup_data()
  File "/usr/lib/python3/dist-packages/postgresql/lib/__init__.py", line 398, in __getattr__
    bs = BoundSymbol(sym, db)
  File "/usr/lib/python3/dist-packages/postgresql/lib/__init__.py", line 288, in __init__
    ps = database.prepare(symbol)
  File "/usr/lib/python3/dist-packages/postgresql/driver/pq3.py", line 2352, in prepare
    ps._fini()
  File "/usr/lib/python3/dist-packages/postgresql/driver/pq3.py", line 1482, in _fini
    self._output_io = typio.resolve_descriptor(tupdesc, 1)
  File "/usr/lib/python3/dist-packages/postgresql/driver/pq3.py", line 220, in resolve_descriptor
    (self.resolve(x[3]) or (None, None))[index] for x in desc
  File "/usr/lib/python3/dist-packages/postgresql/driver/pq3.py", line 220, in <listcomp>
    (self.resolve(x[3]) or (None, None))[index] for x in desc
  File "/usr/lib/python3/dist-packages/postgresql/driver/pq3.py", line 243, in resolve
    typio = builtins(typid)
  File "/usr/lib/python3/dist-packages/postgresql/types/io/__init__.py", line 96, in resolve
    module_io.update(load(io).oid_to_io)
  File "/usr/lib/python3/dist-packages/postgresql/types/io/__init__.py", line 89, in load
    return __import__(__name__ + '.' + relmod, fromlist = True, level = 1)
KeyError: "'__name__' not in globals"

This used to work in 12.10. Accessing the database is possible by using other tools (e.g., psql -h 127.0.0.1 -U therusername the databasename). The postgres server is postgresql-9.1 (9.1.9-1ubuntu1). If more information is necessary, please let me know.

ProblemType: Bug
DistroRelease: Ubuntu 13.04
Package: python3-postgresql 1.0.2-1build2
ProcVersionSignature: Ubuntu 3.8.0-21.32-generic 3.8.8
Uname: Linux 3.8.0-21-generic x86_64
ApportVersion: 2.9.2-0ubuntu8
Architecture: amd64
Date: Wed May 22 07:00:41 2013
InstallationDate: Installed on 2013-03-07 (75 days ago)
InstallationMedia: Ubuntu 12.10 "Quantal Quetzal" - Release amd64 (20121017.5)
MarkForUpload: True
ProcEnviron:
 TERM=xterm
 PATH=(custom, no user)
 XDG_RUNTIME_DIR=<set>
 LANG=en_GB.UTF-8
 SHELL=/bin/bash
SourcePackage: py-postgresql
UpgradeStatus: Upgraded to raring on 2013-04-27 (24 days ago)

Revision history for this message
Ulf Mehlig (umehlig) wrote :
Ulf Mehlig (umehlig)
description: updated
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in py-postgresql (Ubuntu):
status: New → Confirmed
Revision history for this message
Tim Tugendhat (tugi) wrote :

I can confirm this.
Since updating to raring, I have the same issue and can not connect to my db.
Any easy fixes?

Revision history for this message
Atila (atilaromero) wrote :

I was having the same error message, but fixed it installing postgresql-client (which I had removed some days before).
Anyone having this issue even with postgresql-client installed?

Revision history for this message
Atila (atilaromero) wrote :

No, false alarm, still confirmed even with postgresql-client.

Revision history for this message
Atila (atilaromero) wrote :

Workaround:
in file /usr/lib/python3/dist-packages/postgresql/types/io/__init__.py
change line 89
        return __import__(__name__ + '.' + relmod, fromlist = True, level = 1)
to
        return __import__(__name__ + '.' + relmod, fromlist = True)

Worked for me, but I'm not sure if it breaks something else.

tags: added: saucy
Revision history for this message
Patrik Lundquist (patrik-lundquist) wrote :

Version 1.0.2 doesn't support Python 3.3 properly.

It was fixed upstream with commit https://github.com/python-postgres/fe/commit/272edfcd2a008aba1b97170a2138e8a91cb67177

Launchpad needs to import a newer upstream version.

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "Patch for postgresql/types/io/__init__.py" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Changed in py-postgresql (Ubuntu):
status: Confirmed → Triaged
importance: Undecided → High
Revision history for this message
William Grzybowski (william88) wrote :

This should have been fixed in 1.1.0

Changed in py-postgresql (Ubuntu):
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.