problem about cx_Oracle

V

Vincent

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
 
V

Vincent

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top