Could it be the case that your Django/Oracle user has the correct
privileges, but the tables aren't in the user's default
schema/tablespace?  Django queries won't prepend the schema name,
ever, so you need to ensure that either the tables were created or
owned by the connecting user, or that synonyms exist so that "SELECT *
FROM mytable" works, not just "SELECT * FROM myschema.mytable".

Did you use sqlplus itself, or get there through "manage.py dbshell"?
The latter way should ensure that you're connecting exactly as Django
itself does.  You could also do "manage.py shell," then run
"Activity.objects.all()" or somesuch query, then:
"from django.db import connection"
"print connection.queries"
That will show you the exact SQL that seems to be failing, which
hopefully provides us a clue.

I can't imagine why you'd get the environment error only when running
syncdb, if other manage.py commands work.  One other thing you could
perhaps check is ensuring that the directory with the Oracle libraries
is included in LD_LIBRARY_PATH--I know that's sometimes necessary.

I do have a similar setup working on my MacBook Pro, but it's at home
unfortunately so I can't examine my environment directly right now.

Matt

On Fri, Feb 20, 2009 at 1: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