here's the inspectdb models.py file:

from django.db import models

class Subtypes(models.Model):
    id = models.DecimalField(decimal_places=0, max_digits=38,
db_column='ID', primary_key=True) # Field name made lowercase.
    type_id = models.DecimalField(decimal_places=0, null=True,
max_digits=38, db_column='TYPE_ID', blank=True) # Field name made
lowercase.
    name = models.CharField(max_length=255, db_column='NAME',
blank=True) # Field name made lowercase.
    created_at = models.DateField(null=True, db_column='CREATED_AT',
blank=True) # Field name made lowercase.
    updated_at = models.DateField(null=True, db_column='UPDATED_AT',
blank=True) # Field name made lowercase.
    class Meta:
        db_table = u'SUBTYPES'

class Types(models.Model):
    id = models.DecimalField(decimal_places=0, max_digits=38,
db_column='ID', primary_key=True) # Field name made lowercase.
    category_id = models.DecimalField(decimal_places=0, null=True,
max_digits=38, db_column='CATEGORY_ID', blank=True) # Field name made
lowercase.
    name = models.CharField(max_length=255, db_column='NAME',
blank=True) # Field name made lowercase.
    created_at = models.DateField(null=True, db_column='CREATED_AT',
blank=True) # Field name made lowercase.
    updated_at = models.DateField(null=True, db_column='UPDATED_AT',
blank=True) # Field name made lowercase.
    class Meta:
        db_table = u'TYPES'

class Categories(models.Model):
    id = models.DecimalField(decimal_places=0, max_digits=38,
db_column='ID', primary_key=True) # Field name made lowercase.
    name = models.CharField(max_length=255, db_column='NAME',
blank=True) # Field name made lowercase.
    created_at = models.DateField(null=True, db_column='CREATED_AT',
blank=True) # Field name made lowercase.
    updated_at = models.DateField(null=True, db_column='UPDATED_AT',
blank=True) # Field name made lowercase.
    class Meta:
        db_table = u'CATEGORIES'

class Activities(models.Model):
    id = models.DecimalField(decimal_places=0, max_digits=38,
db_column='ID', primary_key=True) # Field name made lowercase.
    category_id = models.DecimalField(decimal_places=0, null=True,
max_digits=38, db_column='CATEGORY_ID', blank=True) # Field name made
lowercase.
    type_id = models.DecimalField(decimal_places=0, null=True,
max_digits=38, db_column='TYPE_ID', blank=True) # Field name made
lowercase.
    subtype_id = models.DecimalField(decimal_places=0, null=True,
max_digits=38, db_column='SUBTYPE_ID', blank=True) # Field name made
lowercase.
    group_id = models.DecimalField(decimal_places=0, null=True,
max_digits=38, db_column='GROUP_ID', blank=True) # Field name made
lowercase.
    subgroup_id = models.DecimalField(decimal_places=0, null=True,
max_digits=38, db_column='SUBGROUP_ID', blank=True) # Field name made
lowercase.
    csu_id = models.CharField(max_length=255, db_column='CSU_ID',
blank=True) # Field name made lowercase.
    code = models.CharField(max_length=255, db_column='CODE',
blank=True) # Field name made lowercase.
    description = models.CharField(max_length=255,
db_column='DESCRIPTION', blank=True) # Field name made lowercase.
    comments = models.TextField(db_column='COMMENTS', blank=True) #
Field name made lowercase.
    created_at = models.DateField(null=True, db_column='CREATED_AT',
blank=True) # Field name made lowercase.
    updated_at = models.DateField(null=True, db_column='UPDATED_AT',
blank=True) # Field name made lowercase.
    class Meta:
        db_table = u'ACTIVITIES'

class SchemaMigrations(models.Model):
    version = models.CharField(unique=True, max_length=255,
db_column='VERSION') # Field name made lowercase.
    class Meta:
        db_table = u'SCHEMA_MIGRATIONS'

On Feb 20, 3:26 pm, Matt Boersma <m...@sprout.org> wrote:
> Ah...I think specifying db_table as "ACTIVITY_CODE.CATEGORIES" is the
> problem.  We don't really have schema support in Django (yes, there's
> a bug recorded for this issue), and unfortunately the approach of
> specifying "schema.table" as the table name will not work.
>
> You'll probably have to do something like:
> CREATE OR REPLACE SYNONYM categories FOR activity_code.categories;
> And repeat for the relevant tables, views, or sequences.
>
> This is particularly problematic for Oracle, which nearly always uses
> multiple schemas and specific permission grants in Real World (tm)
> schemas.  We tried a couple quick, Oracle-specific fixes in the past,
> but they were insufficient, and thus we're pinning our hopes on the
> "general schema support" enhancement coming someday.
>
> Shorter me: "What Ian said."
>
> On Fri, Feb 20, 2009 at 2:15 PM, Brandon Taylor <btaylordes...@gmail.com> 
> wrote:
>
> > Ok, now I am absolutely confounded...
>
> > I ran: manage.py inspectdb > models.py
>
> > Then I tried to get objects from the models THAT IT CREATED FOR ME -
> > same friggin' error!
>
> > What in the world is up with this thing? I'm at a loss.
>
> > b
>
> > On Feb 20, 3:08 pm, Brandon Taylor <btaylordes...@gmail.com> wrote:
> >> Hi Ian,
>
> >> Here's her's the quick model I wrote to try to select *something*:
>
> >> class TestCategory(models.Model):
> >>     name = models.CharField(max_length=255)
> >>     class Meta:
> >>         db_table = 'ACTIVITY_CODE.CATEGORIES'
>
> >> If I connect via dbshell from my project, I can do: select * from
> >> categories;
>
> >> and I get 11 records back, which is correct. But, if I try to retrieve
> >> these via:
>
> >> from my_app.models import TestCategory
> >> from django.shortcuts import render_to_response
>
> >> def test(request):
> >>     categories = TestCategory.objects.all()
> >>     return render_to_response('test.html', {'categories' ;
> >> categories})
>
> >> I get: DatabaseError: ORA-00942: table or view does not exist
>
> >> ? ? ?
>
> >> On Feb 20, 2:53 pm, Brandon Taylor <btaylordes...@gmail.com> wrote:
>
> >> > Hi Matt,
>
> >> > Thanks for the reply. Well, I can get connected via sqlplus and I can:
> >> > desc activities... not sure what's up from the Django side. The user
> >> > I'm connecting with has correct privileges; my Oracle person has
> >> > triple-checked.
>
> >> > If I try to run a syncdb, I get the Oracle environment handle error,
> >> > even though I've specified that in manage.py. I also have my Oracle
> >> > home spec'd in my .bashrc and .bash_profile. I have no idea what to
> >> > try next. ugh.
>
> >> > b
>
> >> > On Feb 20, 2:33 pm, Matt Boersma <m...@sprout.org> wrote:
>
> >> > > Sorry, ignore my previous reply since you figured it out.
>
> >> > > It sounds like you have the tnsnames.ora and environment set up
> >> > > correctly. (Basically, in settings.py, you should either specify just
> >> > > DATABASE_NAME, so Oracle will use the tnsnames.ora or other lookup
> >> > > mechainism based on that, or else specify all DATABASE_foo parameters
> >> > > including DATABASE_HOST and DATABASE_PORT, which effectively bypasses
> >> > > tnsnames.ora.)
>
> >> > > Did you run "manage.py syncdb" or create the necessary tables
> >> > > otherwise?  Now Django is connecting to Oracle successfully, but
> >> > > simply running a query that references a table it can't find.
>
> >> > > You might try "manage.py dbshell" to drop you into Oracle's sqlplus
> >> > > command line with the same connection parameters Django's dev server
> >> > > would use.  Then try "SELECT * FROM mytable" or "DESC mytable" to see
> >> > > what's visible to those credentials.  If the tables live in a
> >> > > different schema, you may need to create private synonyms to them in
> >> > > the Django user's schema--we nearly always end up with that structure
> >> > > in our Django/Oracle apps.
>
> >> > > Hope this helps,
>
> >> > > Matt
>
> >> > > On Fri, Feb 20, 2009 at 12:50 PM, Brandon Taylor
>
> >> > > <btaylordes...@gmail.com> wrote:
>
> >> > > > OK, I am pretty sure I found out where to put the tns_names.ora file:
> >> > > > $ORACLE_HOME/network/admin
>
> >> > > > But, I'm confused as to how to specify the database name. From the
> >> > > > Django Oracle docs (http://docs.djangoproject.com/en/dev/ref/
> >> > > > databases/?from=olddocs#id9) they have the SID as the DATABASE_NAME
> >> > > > setting.
>
> >> > > > If I set my DATABASE_NAME to my SID, and try to retrieve objects, I
> >> > > > get:
>
> >> > > > DatabaseError: ORA-00942: table or view does not exist
>
> >> > > > ? ? ?
>
> >> > > > b
>
> >> > > > On Feb 20, 1:21 pm, Brandon Taylor <btaylordes...@gmail.com> wrote:
> >> > > >> Hi Matt,
>
> >> > > >> Ok, I modified manage.py to add two environ variables:
>
> >> > > >> import os
> >> > > >> oracle_home = '/Users/bft228/Library/Oracle/instantclient_10_2'
> >> > > >> os.environ['ORACLE_HOME'] = oracle_home
> >> > > >> os.environ['DYLD_LIBRARY_PATH'] = oracle_home
>
> >> > > >> Now I'm getting an error:
> >> > > >> DatabaseError: ORA-12505: TNS:listener does not currently know of 
> >> > > >> SID
> >> > > >> given in connect descriptor
>
> >> > > >> Everything I've found online seems to point to a "tnsnames.ora" file
> >> > > >> that describes the connection information. A co-worker sent me their
> >> > > >> "tnsnames.ora" file, but I'm unsure where to put this in OS X.
>
> >> > > >> My ORACLE_HOME is "/Users/bft228/Library/Oracle/instantclient_10_2"
>
> >> > > >> Thoughts?
> >> > > >> Brandon
>
> >> > > >> On Feb 20, 11:04 am, Matt Boersma <m...@sprout.org> wrote:
>
> >> > > >> > Brandon,
>
> >> > > >> > Usually that error arises from cx_Oracle when the ORACLE_HOME
> >> > > >> > environment variable isn't set.  Try doing "manage.py shell" and
> >> > > >> > looking at what's in os.environ--if you don't see ORACLE_HOME set 
> >> > > >> > to
> >> > > >> > the correct location there, try fixing that first.
>
> >> > > >> > Matt
>
> >> > > >> > On Fri, Feb 20, 2009 at 9:41 AM, Brandon Taylor 
> >> > > >> > <btaylordes...@gmail.com> wrote:
>
> >> > > >> > > Hi everyone,
>
> >> > > >> > > I'm using Oracle instantclient_10_2 (Intel), cx_Oracle-5.0.1, 
> >> > > >> > > OS X
> >> > > >> > > 10.5.6 (Intel), Python 2.6.1 and Django trunk.
>
> >> > > >> > > My built-in server will start up correct, but, when I attempt 
> >> > > >> > > to get
> >> > > >> > > objects for a model, I receive the following error:
>
> >> > > >> > > InterfaceError: Unable to acquire Oracle environment handle
>
> >> > > >> > > Can anyone help me resolve this problem?
>
> >> > > >> > > TIA,
> >> > > >> > > Brandon
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to