When i try the same code from python Shell then it is working fine.

Here is the working output:
>>> import cx_Oracle
>>> from pprint import pprint
>>> connection = cx_Oracle.Connection("%s/%s@%s" % ('foo', 'bar', 'db'))
>>> cursor = cx_Oracle.Cursor(connection)
>>> sql = "SELECT xyz FROM table_name where rownum < 10"
>>> cursor.execute(sql)
[<cx_Oracle.STRING object at 0x33c00>]
>>> data = cursor.fetchall()
>>> pprint(data)
[('Robert Craig',),
 ('Darren Kerr',),
 ('Aviva Garrett',),
 ('Pasvorn Boonmark',),
 ('Dave Wittbrodt',),
 ('Pasvorn Boonmark',),
 ('Rajkumaran Chandrasekaran',),
 ('Pasvorn Boonmark',),
 ('Pasvorn Boonmark',)]


But when i use the same code in django views.py then it does not work
and Getting error as:
Exception Value:

Error while trying to retrieve text for error ORA-01804


def cases(request, db_name, prnum=None, message=''):
    connection = cx_Oracle.Connection("%s/%s@%s" % ('foo', 'bar', 'db'))
    cursor = cx_Oracle.Cursor(connection)
    sql = "SELECT xyz FROM table_name where rownum < 10"
    cursor.execute(sql)
    data = cursor.fetchall()
    pprint(data)
    cursor.close()
    connection.close()
    return render_to_response('web/cases.html', {}, RequestContext(request,
{
     'first': 'test1',
     'last': 'test2',
    }))


Thanks,


On Fri, Apr 22, 2011 at 1:01 AM, Ian <ian.g.ke...@gmail.com> wrote:

> On Apr 21, 11:03 am, kamal sharma <kamalp.sha...@gmail.com> wrote:
> > Error while trying to retrieve text for error ORA-01804
> >
> > Here is my code to fetch the data from database.
> >
> > def cases(request, dbname, prnum=None, message=''):
> >
> >     connection = cx_Oracle.Connection("%s/%s@%s" % ('foo', 'bar',
> 'xyz'))
> >     cursor = cx_Oracle.Cursor(connection)
> >     sql = "SELECT fielname FROM tablename where rownum < 10"
> >     cursor.execute(sql)
> >     names = [row[0] for row in cursor.fetchall()]
> >     cursor.close()
> >     connection.close()
>
> First of all, why are you creating your own connection instead of
> using the Django ORM?
>
> Anyway, the proper way to create a cx_Oracle connection is with the
> cx_Oracle.connect factory function, and the proper way to create a
> cursor is with the connection.cursor() method.  See the cx_Oracle docs
> and the DB-API docs for details.  However, I think there is something
> more going on here.
>
> ORA-01804:      failure to initialize timezone information
> Cause:  The timezone information file was not properly read.
> Action:         Please contact Oracle Customer Support.
>
> This and the fact that cx_Oracle wasn't able to look up the error code
> itself suggest that there may be something wrong with your Oracle
> client installation.  Or it may be that your webserver is also
> blocking access to the files in the client directory.  What happens if
> you try the same code from a Python shell?
>
> --
> 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.
>
>

-- 
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