On Sun, Apr 5, 2009 at 12:59 PM, Mike RA9FTM <[email protected]> wrote:
>
> Hi. I need direct connection to oracle for import some information
> sometimes.
> Here is what I do for first test:
>
>
> def orcl_test(request):
> connstr='scott/ti...@orcl'
> conn = cx_Oracle.connect(connstr)
> curs = conn.cursor()
> curs.execute('select * from dept')
> rows = [row[2] for row in curs.fetchall()]
> conn.close()
> return render_to_response('DekanatImport/test.html', {'rows':
> rows})
>
>
> This django view work, when I first load it in browser. But after
> pressing F5 I have following error.
> By debugging it using PyDev, I found, that it appears after conn =
> cx_Oracle.connect(connstr) string.
>
> I am using Django 1.0, cx_Oracle-5.0.1-10g.win32-py2.6.msi.
>
> raceback (most recent call last):
>
> File "I:\Python26\lib\site-packages\django\core\servers
> \basehttp.py", line 277, in run
> self.result = application(self.environ, self.start_response)
>
> File "I:\Python26\lib\site-packages\django\core\servers
> \basehttp.py", line 634, in __call__
> return self.application(environ, start_response)
>
> File "I:\Python26\lib\site-packages\django\core\handlers\wsgi.py",
> line 239, in __call__
> response = self.get_response(request)
>
> File "I:\Python26\lib\site-packages\django\core\handlers\base.py",
> line 128, in get_response
> return self.handle_uncaught_exception(request, resolver, exc_info)
>
> File "I:\Python26\lib\site-packages\django\core\handlers\base.py",
> line 148, in handle_uncaught_exception
> return debug.technical_500_response(request, *exc_info)
>
> File "I:\Python26\lib\site-packages\django\views\debug.py", line 39,
> in technical_500_response
> html = reporter.get_traceback_html()
>
> File "I:\Python26\lib\site-packages\django\views\debug.py", line 97,
> in get_traceback_html
> 'exception_value': smart_unicode(self.exc_value,
> errors='replace'),
>
> File "I:\Python26\lib\site-packages\django\utils\encoding.py", line
> 35, in smart_unicode
> return force_unicode(s, encoding, strings_only, errors)
>
> File "I:\Python26\lib\site-packages\django\utils\encoding.py", line
> 70, in force_unicode
> raise DjangoUnicodeDecodeError(s, *e.args)
>
> DjangoUnicodeDecodeError: 'utf8' codec can't decode bytes in position
> 11-12: invalid data. You passed in DatabaseError(<cx_Oracle._Error
> object at 0x00D48E60>,) (<class 'cx_Oracle.DatabaseError'>)
>
>
> >
>
Instead of importing cx_oracle directly you should do `from django.db import
connection` which gets you a normal PEP-249 database cursor, but Django
wraps a few of the methods to make it play nice with Unicode and such.
Alex
--
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---