problem about cx_Oracle

Discussion in 'Python' started by Vincent, Jul 16, 2009.

  1. Vincent

    Vincent Guest

    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
     
    Vincent, Jul 16, 2009
    #1
    1. Advertisements

  2. Vincent

    Vincent Guest

    On Jul 16, 12:18 pm, Vincent <> 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.
     
    Vincent, Jul 16, 2009
    #2
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Glenn Stauffer

    cx_Oracle & prepared statements

    Glenn Stauffer, Aug 16, 2003, in forum: Python
    Replies:
    0
    Views:
    1,089
    Glenn Stauffer
    Aug 16, 2003
  2. Benson, John
    Replies:
    1
    Views:
    2,447
    Aurelio Martin
    Jan 28, 2004
  3. Damjan

    a cx_Oracle ORA-01036 problem

    Damjan, May 5, 2005, in forum: Python
    Replies:
    4
    Views:
    2,643
    Damjan
    May 12, 2005
  4. Richard Schulman

    Unicode / cx_Oracle problem

    Richard Schulman, Sep 8, 2006, in forum: Python
    Replies:
    8
    Views:
    4,537
    John Machin
    Sep 16, 2006
  5. Brandon Taylor

    cx_Oracle-5.0 Problem

    Brandon Taylor, Feb 12, 2009, in forum: Python
    Replies:
    2
    Views:
    794
    Brandon Taylor
    Feb 12, 2009
  6. Brandon Taylor
    Replies:
    1
    Views:
    884
    Zvezdan Petkovic
    Feb 25, 2009
  7. Squid

    cx_Oracle problem

    Squid, Sep 15, 2009, in forum: Python
    Replies:
    1
    Views:
    395
    Squid
    Sep 15, 2009
  8. Replies:
    0
    Views:
    337
Loading...