google-code-export / django-pyodbc

Automatically exported from code.google.com/p/django-pyodbc
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

problem creating database tables on syncdb #55

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

I have two users for my sql server instance. Both are owners of separate 
schemas. Running 
syncdb for my first project created the tables perfectly fine. Running syncdb 
for the second 
project (different user) threw an error:

pyodbc.ProgrammingError: ('42S02', "[42S02] [FreeTDS][SQL Server]Invalid object 
name 
'django_content_type'. (208) (SQLPrepare)")

inferring that the database table name is already taken even though the default 
schemas for 
each user are different and naming conflicts don't apply. I know this backend 
doesn't support 
schemas, but... I can open up a raw connection using the pyodbc library and 
create the table 
manually (using the same user, without specifying the schema) and the table is 
created no 
problem.

What is the expected output? What do you see instead?

Because I have two separate db users which own two separate schemas, the tables 
should have 
no issues being created. And this can be done manually through the pyodbc 
driver.

What version of the product are you using? On what operating system?

django-pyodbc  r171
pyodbc v2.1.5
django r10604
OS X 10.5.7

Please provide any additional information below.

Traceback below:

001641ed8d32 ~/development/python/projects/audgendb %  python manage.py syncdb 
--
settings=audgendb.settings.development
Traceback (most recent call last):
  File "manage.py", line 11, in <module>
    execute_manager(settings)
  File "/Users/Byron/development/python/toolbox/django/core/management/__init__.py", line 
359, in execute_manager
    utility.execute()
  File "/Users/Byron/development/python/toolbox/django/core/management/__init__.py", line 
304, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/Byron/development/python/toolbox/django/core/management/base.py", line 195, 
in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/Users/Byron/development/python/toolbox/django/core/management/base.py", line 222, 
in execute
    output = self.handle(*args, **options)
  File "/Users/Byron/development/python/toolbox/django/core/management/base.py", line 351, 
in handle
    return self.handle_noargs(**options)
  File 
"/Users/Byron/development/python/toolbox/django/core/management/commands/syncdb.
py", 
line 99, in handle_noargs
    emit_post_sync_signal(created_models, verbosity, interactive)
  File "/Users/Byron/development/python/toolbox/django/core/management/sql.py", line 205, 
in emit_post_sync_signal
    interactive=interactive)
  File "/Users/Byron/development/python/toolbox/django/dispatch/dispatcher.py", line 150, in 
send
    response = receiver(signal=self, sender=sender, **named)
  File 
"/Users/Byron/development/python/toolbox/django/contrib/auth/management/__init__
.py", 
line 25, in create_permissions
    ctype = ContentType.objects.get_for_model(klass)
  File "/Users/Byron/development/python/toolbox/django/contrib/contenttypes/models.py", line 
31, in get_for_model
    defaults = {'name': smart_unicode(opts.verbose_name_raw)},
  File "/Users/Byron/development/python/toolbox/django/db/models/manager.py", line 123, in 
get_or_create
    return self.get_query_set().get_or_create(**kwargs)
  File "/Users/Byron/development/python/toolbox/django/db/models/query.py", line 297, in 
get_or_create
    return self.get(**kwargs), False
  File "/Users/Byron/development/python/toolbox/django/db/models/query.py", line 269, in get
    num = len(clone)
  File "/Users/Byron/development/python/toolbox/django/db/models/query.py", line 68, in 
__len__
    self._result_cache = list(self.iterator())
  File "/Users/Byron/development/python/toolbox/django/db/models/query.py", line 207, in 
iterator
    for row in self.query.results_iter():
  File "/Users/Byron/development/python/toolbox/django/db/models/sql/query.py", line 276, in 
results_iter
    for rows in self.execute_sql(MULTI):
  File "/Users/Byron/development/python/toolbox/django/db/models/sql/query.py", line 2310, 
in execute_sql
    cursor.execute(sql, params)
  File "/Users/Byron/development/python/toolbox/django/db/backends/util.py", line 19, in 
execute
    return self.cursor.execute(sql, params)
  File "/Users/Byron/development/python/toolbox/sql_server/pyodbc/base.py", line 260, in 
execute
    return self.cursor.execute(sql, params)
pyodbc.ProgrammingError: ('42S02', "[42S02] [FreeTDS][SQL Server]Invalid object 
name 
'django_content_type'. (208) (SQLPrepare)")

Original issue reported on code.google.com by bjr...@gmail.com on 15 Jun 2009 at 7:07

GoogleCodeExporter commented 9 years ago
I'm afraid you will need to get a trace of the SQL generated both by Django and 
by
bare pyodbc so we can compare what's the difference among them.

Original comment by cra...@gmail.com on 19 Jun 2009 at 11:22

GoogleCodeExporter commented 9 years ago
This looks like the django's #15610 
(https://code.djangoproject.com/ticket/15610). Then django tries to find 
content types in ODBC database (not default) but it's not there.

Original comment by 4glitch on 15 Jul 2013 at 7:34