Code

Opened 6 years ago

Closed 6 years ago

#7090 closed (fixed)

postgresql_psycopg2 blows up when you try to create a cursor with postgresql 8.3.1 on windows

Reported by: grand@… Owned by: nobody
Component: Database layer (models, ORM) Version: 0.96
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

On windows, configured to work with postgresql 8.3.1 creating a cursor blows up due to the format of the postgresql version string.

>>> from django.db import connection
>>> cursor = connection.cursor()
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "C:\python25\lib\site-packages\django\db\backends\postgresql_psycopg2\base.py", line 57, in cursor
    postgres_version = [int(val) for val in cursor.fetchone()[0].split()[1].split('.')]
ValueError: invalid literal for int() with base 10: '1,'

The version string returned by postgresql was 'PostgreSQL 8.3.1, compiled by Visual C++ build 1400'
It is choking on the comma after the version number. Here is a modified base.py line 57 that fixes the problem:

            postgres_version = [int(val) for val in cursor.fetchone()[0].split()[1].replace(',','').split('.')]

Attachments (0)

Change History (1)

comment:1 Changed 6 years ago by Alex

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to fixed
  • Status changed from new to closed

This is fixed in trunk r7415.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.