Opened 6 years ago

Closed 6 years ago

#6987 closed (duplicate) syncdb: Error with the PostgreSQL version.

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


When I tried to initialize the database for the first time, I got the following error.

C:\django\blog>python syncdb
Traceback (most recent call last):
  File "", line 11, in <module>
  File "C:\Python25\Lib\site-packages\django\core\", line 1672, in execute_manager
    execute_from_command_line(action_mapping, argv)
  File "C:\Python25\Lib\site-packages\django\core\", line 1571, in execute_from_command_line
    action_mapping[action](int(options.verbosity), options.interactive)
  File "C:\Python25\Lib\site-packages\django\core\", line 504, in syncdb
    cursor = connection.cursor()
  File "C:\Python25\Lib\site-packages\django\db\backends\postgresql_psycopg2\", 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,'

Doing a SELECT version() returns: ('PostgreSQL 8.3.1, compiled by Visual C++ build 1400',)
So there is a trailing comma after the version number.

Attachments (0)

Change History (2)

comment:1 Changed 6 years ago by Manuel Lanctot <sensoz@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

My solution was as followed.

In django\db\backends\postgresql_psycopg2\, line 57:


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


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

comment:2 Changed 6 years ago by russellm

  • Resolution set to duplicate
  • Status changed from new to closed

Essentially a dupe of #6433.

Add Comment

Modify Ticket

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

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

Note: See TracTickets for help on using tickets.