[Tutor] Operational Error. --HELP
bijoy franco
bijoy.webworkers at gmail.com
Tue Mar 31 21:23:05 CEST 2009
I tried following query as well.
code:
infunction_curs.execute('SELECT * FROM table_book')
This also throws the same error
Bijoy
On Wed, Apr 1, 2009 at 12:42 AM, bob gailer <bgailer at gmail.com> wrote:
> bijoy franco wrote:
>>
>> Hi,
>>
>> When used in psql interface directly, all Database operation queries
>> works perfectly fine.
>>
>
> So now we have a different query than the first time!
>
> I serioiusly doubt that
>
> SELECT book_name FROM table_book WHERE book_name=fgfd
>
> works in the interface.
>
> Or if it does work then fgfd must have been previously defined.
>
> I think the query should be:
>
> SELECT book_name FROM table_book WHERE book_name='fgfd'
>
>
>> Pls find the full code and error below
>>
>> code:
>>
>> import pgdb
>>
>> __metaclass__=type
>>
>> class addbook:
>>
>>
>> conn=pgdb.connect(dsn='localhost:secondbooks',user='postgres',password='postgres1')
>> curs=conn.cursor()
>>
>> def addBook(self):
>> name=raw_input("Enter Book Name: ")
>> subject=raw_input("Enter Book Subject: ")
>> language=raw_input("Enter Book Language: ")
>> category=raw_input("Enter Book Category: ")
>> author=raw_input("Enter Book Author: ")
>> publication=raw_input("Enter Book Publication: ")
>> cost=raw_input("Enter Book Cost: ")
>> purchasedyear=raw_input("Enter Book Purchased Year: ")
>>
>> infunction_curs=self.curs
>> infunction_curs.execute('SELECT book_name FROM
>> table_book WHERE book_name=%s' %name)
>>
>>
>> conn.commit()
>> conn.close()
>>
>> def main():
>> addbookinstance=addbook()
>> addbookinstance.addBook()
>>
>> if __name__=='__main__':main()
>>
>> error code:
>>
>> Traceback (most recent call last):
>> File "/home/bijoy/python/secondbooks/secondbooks_main.py", line 44,
>> in <module>
>> if __name__=='__main__':main()
>> File "/home/bijoy/python/secondbooks/secondbooks_main.py", line 42, in
>> main
>> addbookinstance.addBook()
>> File "/home/bijoy/python/secondbooks/secondbooks_main.py", line 24, in
>> addBook
>> infunction_curs.execute('SELECT book_name FROM table_book WHERE
>> book_name=%s' %name)
>> File "/usr/lib/python2.5/site-packages/pgdb.py", line 174, in execute
>> self.executemany(operation, (params,))
>> File "/usr/lib/python2.5/site-packages/pgdb.py", line 197, in executemany
>> raise OperationalError, "internal error in '%s': %s" % (sql,err)
>> pg.OperationalError: internal error in 'SELECT book_name FROM
>> table_book WHERE book_name=fgfd': error return without exception set
>>
>>
>>
>> thanks
>>
>> Bijoy
>>
>>
>> On Wed, Apr 1, 2009 at 12:20 AM, bob gailer <bgailer at gmail.com> wrote:
>>
>>>
>>> bijoy franco wrote:
>>>
>>>>
>>>> Hi,
>>>>
>>>> Python throws OperationalError while trying to do any database
>>>> operations. I am using pgdb module.
>>>>
>>>> Code:
>>>>
>>>> import pgdb
>>>>
>>>> __metaclass__=type
>>>>
>>>> class addbook:
>>>>
>>>>
>>>> conn=pgdb.connect(dsn='localhost:secondbooks',user='postgres',password='postgres1')
>>>> curs=conn.cursor()
>>>>
>>>> def addBook(self):
>>>>
>>>> infunction_curs=self.curs
>>>> infunction_curs.execute('SELECT * FROM table_book')
>>>>
>>>>
>>>> error code:
>>>>
>>>> File "/usr/lib/python2.5/site-packages/pgdb.py", line 197, in
>>>> executemany
>>>> raise OperationalError, "internal error in '%s': %s" % (sql,err)
>>>> pg.OperationalError: internal error in 'SELECT * FROM table_book': error
>>>> return without exception set
>>>>
>>>> i am not able to do any database operations apart from opening Conection
>>>> and assaigning cursor object.
>>>>
>>>> how do i solve this. pls help
>>>>
>>>
>>> 1 - please post in plain text - I reformatted it so I could read it.
>>> 2 - please post the rest of the code and the rest of the traceback so we
>>> can see where addbook is instantiated and where addBook is called. It is
>>> impossible for me to diagnose this without that information.
>>> 3 - have you verified in some other way that SELECT * FROM table_book is
>>> acceptable to postgresql?
>>> 4 - please reply to the list
>>>
>>>
>>>>
>>>> Thanks in advance
>>>>
>>>> Bijoy
>>>>
>>>>
>>>
>>> Welcome in retrospect.
>>>
>>
>>
>
>
> --
> Bob Gailer
> Chapel Hill NC
> 919-636-4239
>
More information about the Tutor
mailing list