2011-01-10 15 views
1

リモートOracleデータベースのテーブルでDjango ORMを使用して簡単なクエリを実行すると、次のエラーが発生します。リモートOracleデータベースでDjangoを使用していて、 "テーブルが存在しません"というエラーが発生しました

>>> from apps.dl.models import Article 
>>> Article.objects.using('dl').all() 
Traceback (most recent call last): 
    File "<console>", line 1, in <module> 
    File "/var/www/acm.local/server-env/lib/python2.6/site-packages/django/db/models/query.py", line 68, in __repr__ 
    data = list(self[:REPR_OUTPUT_SIZE + 1]) 
    File "/var/www/acm.local/server-env/lib/python2.6/site-packages/django/db/models/query.py", line 83, in __len__ 
    self._result_cache.extend(list(self._iter)) 
    File "/var/www/acm.local/server-env/lib/python2.6/site-packages/django/db/models/query.py", line 269, in iterator 
    for row in compiler.results_iter(): 
    File "/var/www/acm.local/server-env/lib/python2.6/site-packages/django/db/models/sql/compiler.py", line 672, in results_iter 
    for rows in self.execute_sql(MULTI): 
    File "/var/www/acm.local/server-env/lib/python2.6/site-packages/django/db/models/sql/compiler.py", line 727, in execute_sql 
    cursor.execute(sql, params) 
    File "/var/www/acm.local/server-env/lib/python2.6/site-packages/django/db/backends/util.py", line 15, in execute 
    return self.cursor.execute(sql, params) 
    File "/var/www/acm.local/server-env/lib/python2.6/site-packages/django/db/backends/oracle/base.py", line 507, in execute 
    return self.cursor.execute(query, self._param_generator(params)) 
DatabaseError: ORA-00942: table or view does not exist 

はここで私が使用しているモデルです。

class Article(models.Model): 
    id = models.CharField(primary_key=True, max_length=12, db_column="ID") 
    publication_id = models.CharField(blank=True, null=True, max_length=12, db_column="PUBLICATION_ID") 
    issue_id = models.CharField(blank=True, null=True, max_length=12, db_column="ISSUE_ID") 
    section_id = models.IntegerField(blank=True, null=True, max_length=12, db_column="SECTION_ID") 
    title = models.CharField(blank=True, null=True, max_length=512, db_column="TITLE") 
    subtitle = models.CharField(blank=True, null=True, max_length=512, db_column="SUBTITLE") 
    page_range = models.CharField(blank=True, null=True, max_length=32, db_column="PAGE_RANGE") 
    start_page = models.CharField(blank=True, null=True, max_length=12, db_column="START_PAGE") 
    end_page = models.CharField(blank=True, null=True, max_length=12, db_column="END_PAGE") 
    article_no = models.CharField(blank=True, null=True, max_length=12, db_column="ARTICLE_NO") 
    doi = models.CharField(blank=True, null=True, max_length=128, db_column="DOI") 
    publication_date = models.DateTimeField(null=True, max_length=7, db_column="PUBLICATION_DATE") 
    author_names = models.CharField(blank=True, null=True, max_length=4000, db_column="AUTHOR_NAMES") 
    sort_key = models.IntegerField(null=True, db_column="SORT_KEY") 
    abstract = models.TextField(blank=True, null=True, db_column="ABSTRACT") 
    citation_url = models.CharField(blank=True, null=True, max_length=128, db_column="CITATION_URL") 
    notes = models.CharField(blank=True, null=True, max_length=512, db_column="NOTES") 
    downloads6 = models.IntegerField(null=True, db_column="DOWNLOADS6") 
    downloads12 = models.IntegerField(null=True, db_column="DOWNLOADS12") 
    citings = models.IntegerField(null=True, db_column="CITINGS") 
    created_date = models.DateTimeField(db_column="CREATED_DATE") 
    short_abstract = models.CharField(blank=True, null=True, max_length=4000, db_column="SHORT_ABSTRACT") 
    teaser = models.TextField(blank=True, null=True, max_length=512, db_column="TEASER") 
    cacm_id = models.CharField(blank=True, null=True, max_length=12, db_column="CACM_ID") 
    cacm_ref = models.CharField(blank=True, null=True, max_length=512, db_column="CACM_REF") 
    cacm_only = models.CharField(blank=True, null=True, max_length=1, db_column="CACM_ONLY") 
    article_type = models.CharField(blank=True, null=True, max_length=32, db_column="ARTICLE_TYPE") 
    article_url = models.TextField(blank=True, null=True, max_length=128, db_column="ARTICLE_TYPE") 

    class Meta: 
     db_tablespace = "DLDATA" 
     db_table = "ARTICLES" 
     managed = False 

私は前にOracleデータベースで働いたことがありませんので、私は、この問題をデバッグする方法に関してわかりませんよ。 Navicatを使って見ることができるので、私のユーザはテーブルを見る権限があると確信しています。どのように私はこの問題を解決することができますかどんなヒント?

+0

複数のデータベースを使用していますか? – mbarkhau

答えて

6

このエラーは、Djangoのバグによって発生しています。 Oracleでスキーマを使用していたため、私はそれを得ていました。これを回避する方法は(今のところ)

class MyModel(models.Model): 
    # Model stuff...   

    class Meta: 
     # ... 
     db_table = '"DLDATA"."ARTICLES"' 
関連する問題