Opened 17 years ago

Closed 17 years ago

#4603 closed (duplicate)

Psycopg2 - error setting time zone

Reported by: Jonas von Poser Owned by: Adrian Holovaty
Component: Database layer (models, ORM) Version: dev
Severity: Keywords: postgresql psycopg2
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

There's a bug in Psycopg2 that doesn't let connect to the data base:

In [1]: from django.db import connection

In [2]: cursor = connection.cursor()
---------------------------------------------------------------------------
<class 'psycopg2.ProgrammingError'>       Traceback (most recent call last)

/home/*****/<ipython console> in <module>()

/usr/local/lib/python2.5/django/db/backends/postgresql_psycopg2/base.py in cursor(self)
     52         cursor.tzinfo_factory = None
     53         if set_tz:
---> 54             cursor.execute("SET TIME ZONE %s", [settings.TIME_ZONE])
     55         global postgres_version
     56         if not postgres_version:

<class 'psycopg2.ProgrammingError'>: argument formats can't be mixed

http://code.djangoproject.com/browser/django/trunk/django/db/backends/postgresql_psycopg2/base.py#L54



I found the same bug here: http://initd.org/tracker/psycopg/ticket/178


"Please, also note that using lists as arguments is wrong. It works only by chance and would probably raise an error in the future. Use tuples or dictionaries."

Change History (2)

comment:1 by Jonas von Poser, 17 years ago

Using:

postgresql-8.2 8.2.4-0ubuntu0.7.04
psycopg2-2.0.6b2-py2.5-linux-i686.egg

comment:2 by Malcolm Tredinnick, 17 years ago

Resolution: duplicate
Status: newclosed

This is a dupe of #4099. What it will take for that to be fixed is somebody to go through everywhere we are passing paramaters to the database (in the psycopg2 backend) and check they are all tuples or dictionaries. If you could be bothered to do that (since you have the setup already) and attach a patch to the other ticket, that would be great.

Note: See TracTickets for help on using tickets.
Back to Top