Django

Code

Ticket #6987 (closed: duplicate)

Opened 8 months ago

Last modified 8 months ago

manage.py syncdb: Error with the PostgreSQL version.

Reported by: Manuel Lanctot <sensoz@gmail.com> Assigned to: nobody
Milestone: Component: Database layer (models, ORM)
Version: 0.96 Keywords: psycopg2, postgresql, syncdb
Cc: Triage Stage: Unreviewed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

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

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

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

Change History

04/08/08 14:19:41 changed by Manuel Lanctot <sensoz@gmail.com>

  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

My solution was as followed.

In django\db\backends\postgresql_psycopg2\base.py, line 57:

Replace

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

With

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

04/08/08 18:54:56 changed by russellm

  • status changed from new to closed.
  • resolution set to duplicate.

Essentially a dupe of #6433.


Add/Change #6987 (manage.py syncdb: Error with the PostgreSQL version.)




Change Properties
Action