Opened 8 years ago

Closed 7 years ago

#14566 closed (invalid)

Multiple database issue v1.2.3 - Django reading the wrong database

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

Description (last modified by Alex Gaynor)

I have two PostgreSQL (postgresql_psycopg2) databases defined in my settings; default and scenes.

If I perform a filter using the 'scenes' DB I get the expected results:

[<Scene: Scene object>, <Scene: Scene object>]

If I perform a get(), Django seems to get completely confused and appears to read the data from the default database:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/lib/python2.6/site-packages/django/db/models/", line 132, in get
    return self.get_query_set().get(*args, **kwargs)
  File "/usr/lib/python2.6/site-packages/django/db/models/", line 336, in get
    num = len(clone)
  File "/usr/lib/python2.6/site-packages/django/db/models/", line 81, in __len__
    self._result_cache = list(self.iterator())
  File "/usr/lib/python2.6/site-packages/django/db/models/", line 269, in iterator
    for row in compiler.results_iter():
  File "/usr/lib/python2.6/site-packages/django/db/models/sql/", line 672, in results_iter
    for rows in self.execute_sql(MULTI):
  File "/usr/lib/python2.6/site-packages/django/db/models/sql/", line 727, in execute_sql
    cursor.execute(sql, params)
  File "/usr/lib/python2.6/site-packages/django/db/backends/", line 15, in execute
    return self.cursor.execute(sql, params)
  File "/usr/lib/python2.6/site-packages/django/db/backends/postgresql_psycopg2/", line 44, in execute
    return self.cursor.execute(query, args)
DatabaseError: relation "scene" does not exist
LINE 1: ...le", "scene"."datasets", "scene"."transform" FROM "scene" WH...

Anyone else seen this?


Change History (3)

comment:1 Changed 8 years ago by Alex Gaynor

Description: modified (diff)

Reformatted description, please use preview.

comment:2 Changed 8 years ago by Johannes Dollinger

Is that a typo in the description or have you really swapped get and using ?

# vs

comment:3 Changed 7 years ago by Alex Gaynor

Resolution: invalid
Status: newclosed

No response to emulbreh's query, as it looks like a bug in the user's code I'm going to close for now, feel free to reopen with more information.

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