Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > problem about cx_Oracle

Reply
Thread Tools

problem about cx_Oracle

 
 
Vincent
Guest
Posts: n/a
 
      07-16-2009
hi, all:

i am using cx_oracle now.

i write code as below:

def __getfields_by_tbname(self,tbname):
cursor = self.ora_db.cursor()
print tbname
sql = 'select * from %s where rownum <=2' % tbname
print sql
cursor = cursor.execute(sql)
return self.getfields(cursor)

and i got a error, it's message is :
JRYZCFZB_X_ZQY
select * from JRYZCFZB_X_ZQY where rownum <=2
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "c:/vincent/wd/django/mysite/mysite\..\mysite\tools
\data_convert.py", line 107, in convert
self.convert_table(tbname)
File "c:/vincent/wd/django/mysite/mysite\..\mysite\tools
\data_convert.py", line 94, in convert_table
field_list = self.__getfields_by_tbname(tbname)
File "c:/vincent/wd/django/mysite/mysite\..\mysite\tools
\data_convert.py", line 38, in __getfields_by_tbname
cursor = cursor.execute(sql)
TypeError: expecting None or a string

i'm sure the cursor instance is not None.
could anybody give me sussgestion? i will apreciate it.

vincent
 
Reply With Quote
 
 
 
 
Vincent
Guest
Posts: n/a
 
      07-16-2009
On Jul 16, 12:18*pm, Vincent <(E-Mail Removed)> wrote:
> hi, all:
>
> i am using cx_oracle now.
>
> i write code as below:
>
> def __getfields_by_tbname(self,tbname):
> * * * * cursor = self.ora_db.cursor()
> * * * * print tbname
> * * * * sql = 'select * from %s where rownum <=2' % tbname
> * * * * print sql
> * * * * cursor = cursor.execute(sql)
> * * * * return self.getfields(cursor)
>
> and i got a error, it's message is :
> JRYZCFZB_X_ZQY
> select * from JRYZCFZB_X_ZQY where rownum <=2
> Traceback (most recent call last):
> * File "<input>", line 1, in <module>
> * File "c:/vincent/wd/django/mysite/mysite\..\mysite\tools
> \data_convert.py", line 107, in convert
> * * self.convert_table(tbname)
> * File "c:/vincent/wd/django/mysite/mysite\..\mysite\tools
> \data_convert.py", line 94, in convert_table
> * * field_list = self.__getfields_by_tbname(tbname)
> * File "c:/vincent/wd/django/mysite/mysite\..\mysite\tools
> \data_convert.py", line 38, in __getfields_by_tbname
> * * cursor = cursor.execute(sql)
> TypeError: expecting None or a string
>
> i'm sure the cursor instance is not None.
> could anybody give me sussgestion? i will apreciate it.
>
> vincent


i have the answer now.

the variant sql is unicode.

i neet to convert it to string.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cx_Oracle-5.0 Problem Brandon Taylor Python 2 02-12-2009 07:24 PM
Unicode / cx_Oracle problem Richard Schulman Python 8 09-16-2006 09:03 PM
a cx_Oracle ORA-01036 problem Damjan Python 4 05-12-2005 04:02 PM
RE: Oracle beginner problem: can't connect to Oracle using cx_Oracle Pieter Claerhout Python 0 01-28-2004 01:13 PM
Oracle beginner problem: can't connect to Oracle using cx_Oracle Benson, John Python 1 01-28-2004 12:55 PM



Advertisments