By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,035 Members | 1,388 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,035 IT Pros & Developers. It's quick & easy.

AttributeError help

P: 18
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(connString)
>>> curs=orc1.cursor
>>> sql="SELECT COUNT(*) FROM PS_PEPTIDES WHERE RANK = 1"
>>> curs.execute(sql)
Traceback (most recent call last):
File "<pyshell#4>", line 1, in -toplevel-
curs.execute(sql)
AttributeError: 'builtin_function_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.
Nov 29 '06 #1
Share this Question
Share on Google+
5 Replies


P: 18
Well, this is embarassing but I figured out my problem:
curs=orc1.cursor
should be
curs=orc1.cursor()
I am surprised the original statement did not return an error but it works now!
Nov 29 '06 #2

bartonc
Expert 5K+
P: 6,596
Well, this is embarassing but I figured out my problem:
curs=orc1.cursor
should be
curs=orc1.cursor()
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.
Nov 29 '06 #3

bartonc
Expert 5K+
P: 6,596
By the way, Welcome to the python forum. I hope you keep posting,
barton
Nov 29 '06 #4

P: 18
I fear I will be visiting a lot.

Thanks!
Nov 30 '06 #5

bartonc
Expert 5K+
P: 6,596
I fear I will be visiting a lot.

Thanks!
That's great!
Nov 30 '06 #6

Post your reply

Sign in to post your reply or Sign up for a free account.