AttributeError help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • PythonNewbie
    New Member
    • Nov 2006
    • 18

    AttributeError help

    Hello folks, I wrote this code for connection module yesterday to extract data from an Oracle db and it worked - I was happy and went home for the evening thinking today I will write the rest of the program. However to my dismay, the same code does not work today and I am not sure what is the problem. Here is the code and the error:
    >>> import cx_Oracle
    >>> orc1=cx_Oracle. connect(connStr ing)
    >>> curs=orc1.curso r
    >>> sql="SELECT COUNT(*) FROM PS_PEPTIDES WHERE RANK = 1"
    >>> curs.execute(sq l)
    Traceback (most recent call last):
    File "<pyshell#4 >", line 1, in -toplevel-
    curs.execute(sq l)
    AttributeError: 'builtin_functi on_or_method' object has no attribute 'execute'

    I replaced the login information with dummy variable "connString "in the above code. Some help on the matter would be greatly appreciated - I tried to do google search and search on this board to see if I can find something that would help but was not successful.
  • PythonNewbie
    New Member
    • Nov 2006
    • 18

    #2
    Well, this is embarassing but I figured out my problem:
    curs=orc1.curso r

    should be
    curs=orc1.curso r()

    I am surprised the original statement did not return an error but it works now!

    Comment

    • bartonc
      Recognized Expert Expert
      • Sep 2006
      • 6478

      #3
      Originally posted by PythonNewbie
      Well, this is embarassing but I figured out my problem:
      curs=orc1.curso r

      should be
      curs=orc1.curso r()

      I am surprised the original statement did not return an error but it works now!
      This is not an error because python lets you do thinks like assign functions to variables. So
      c=curs() would work after the above assignment.

      Comment

      • bartonc
        Recognized Expert Expert
        • Sep 2006
        • 6478

        #4
        By the way, Welcome to the python forum. I hope you keep posting,
        barton

        Comment

        • PythonNewbie
          New Member
          • Nov 2006
          • 18

          #5
          I fear I will be visiting a lot.

          Thanks!

          Comment

          • bartonc
            Recognized Expert Expert
            • Sep 2006
            • 6478

            #6
            Originally posted by PythonNewbie
            I fear I will be visiting a lot.

            Thanks!
            That's great!

            Comment

            Working...