Cursor SQL Error

View: New views
12 Messages — Rating Filter:   Alert me  

Cursor SQL Error

by Jacek Kałucki :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I'm trying to create simple application setup wizard and I encountered a
problem.
My code is:
         conn = dabo.db.dConnection(self.connectInfo)
         cursor = conn.getDaboCursor()
         cursor.execute("select * from users")

For SQLite backend everything works fine, but for PostgreSQL,
execute raises an exception:
      File "c:\python25\lib\site-packages\dabo\db\dCursorMixin.py", line
332, in execute
         raise dException.DBQueryException(errMsg, sql)
     dabo.dException.DBQueryException: current transaction is aborted,
commands ignored until end of transaction block
     SQL: select * from users

Pure psycopg2 cursor also works correctly, but Dabo cursor don't.
What I'm doing wrong?

--
Regards
Jacek Kałucki



_______________________________________________
Post Messages to: Dabo-users@...
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/4AF6154D.3010506@...

Re: Cursor SQL Error

by Ed Leafe :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Nov 7, 2009, at 6:48 PM, Jacek Kałucki wrote:

> I'm trying to create simple application setup wizard and I  
> encountered a
> problem.
> My code is:
>         conn = dabo.db.dConnection(self.connectInfo)
>         cursor = conn.getDaboCursor()
>         cursor.execute("select * from users")
>
> For SQLite backend everything works fine, but for PostgreSQL,
> execute raises an exception:
>      File "c:\python25\lib\site-packages\dabo\db\dCursorMixin.py",  
> line
> 332, in execute
>         raise dException.DBQueryException(errMsg, sql)
>     dabo.dException.DBQueryException: current transaction is aborted,
> commands ignored until end of transaction block
>     SQL: select * from users
>
> Pure psycopg2 cursor also works correctly, but Dabo cursor don't.
> What I'm doing wrong?


        Did you run any other queries before this that might have left things  
in an aborted state? If not, it must have been one of the Dabo  
cursor's internal queries. What version of PostgreSQL are you working  
with?


-- Ed Leafe



_______________________________________________
Post Messages to: Dabo-users@...
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/0F793569-887D-4AAB-BE82-40A89BEFFCB4@...

Re: Cursor SQL Error

by Jacek Kałucki :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Użytkownik Ed Leafe napisał:
> Did you run any other queries before this that might have left things
> in an aborted state? If not, it must have been one of the Dabo
> cursor's internal queries. What version of PostgreSQL are you working
> with?
>    

I know about "aborted state" behaviour.
No I didn't run any SQL statements before for this connection.
This is the exact code: create connection, cursor, then execute query.
I'm using PosthreSQL 8.3.7.1400.
For Firebird this code raises other exception:
     -901, 'begin transaction: \n  invalid parameter in transaction
parameter block'
I feel a bit confused...

--
Regards
Jacek Kałucki

_______________________________________________
Post Messages to: Dabo-users@...
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/4AF698E7.3070208@...

Re: Cursor SQL Error

by Jacek Kałucki :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Użytkownik Jacek Kałucki napisał:
> For Firebird this code raises other exception:
>       -901, 'begin transaction: \n  invalid parameter in transaction
> parameter block'
> I feel a bit confused...
>    

With Firebird, it was kinterbasdb error (I'm using FB 2.1).
After patching kinterbasdb.__init__.py it works correctly now.
But problem with PostgreSQL still remains :)

--
Regards
Jacek Kałucki

_______________________________________________
Post Messages to: Dabo-users@...
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/4AF69C6A.2080909@...

Re: Cursor SQL Error

by Uwe Grauer-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Jacek Kałucki wrote:

> Użytkownik Jacek Kałucki napisał:
>> For Firebird this code raises other exception:
>>       -901, 'begin transaction: \n  invalid parameter in transaction
>> parameter block'
>> I feel a bit confused...
>>    
>
> With Firebird, it was kinterbasdb error (I'm using FB 2.1).
> After patching kinterbasdb.__init__.py it works correctly now.
> But problem with PostgreSQL still remains :)
>

I do not understand why patching kinterbasdb.__init__.py is necessary.
The latest kinterbasdb is working fine for me:
http://firebirdsql.org/index.php?op=devel&sub=python

Uwe

_______________________________________________
Post Messages to: Dabo-users@...
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/4AF6B4D6.9090704@...

Re: Cursor SQL Error

by Jacek Kałucki :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Użytkownik Uwe Grauer napisał:

> Jacek Kałucki wrote:
>    
>> Użytkownik Jacek Kałucki napisał:
>>      
>>> For Firebird this code raises other exception:
>>>        -901, 'begin transaction: \n  invalid parameter in transaction
>>> parameter block'
>>> I feel a bit confused...
>>>
>>>        
>> With Firebird, it was kinterbasdb error (I'm using FB 2.1).
>> After patching kinterbasdb.__init__.py it works correctly now.
>> But problem with PostgreSQL still remains :)
>>
>>      
> I do not understand why patching kinterbasdb.__init__.py is necessary.
> The latest kinterbasdb is working fine for me:
> http://firebirdsql.org/index.php?op=devel&sub=python
>    

But I use KInterbasDB 3.2:
     
https://bugs.launchpad.net/ubuntu/+source/python-kinterbasdb/+bug/369589

--
Regards
Jacek Kałucki

_______________________________________________
Post Messages to: Dabo-users@...
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/4AF6B683.40801@...

Re: Cursor SQL Error

by Uwe Grauer-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Jacek Kałucki wrote:

> Użytkownik Uwe Grauer napisał:
>> Jacek Kałucki wrote:
>>    
>>> Użytkownik Jacek Kałucki napisał:
>>>      
>>>> For Firebird this code raises other exception:
>>>>        -901, 'begin transaction: \n  invalid parameter in transaction
>>>> parameter block'
>>>> I feel a bit confused...
>>>>
>>>>        
>>> With Firebird, it was kinterbasdb error (I'm using FB 2.1).
>>> After patching kinterbasdb.__init__.py it works correctly now.
>>> But problem with PostgreSQL still remains :)
>>>
>>>      
>> I do not understand why patching kinterbasdb.__init__.py is necessary.
>> The latest kinterbasdb is working fine for me:
>> http://firebirdsql.org/index.php?op=devel&sub=python
>>    
>
> But I use KInterbasDB 3.2:
>      
> https://bugs.launchpad.net/ubuntu/+source/python-kinterbasdb/+bug/369589
>

Now you know that using Kinterbasdb 3.3 might be easier. ;-)

Uwe

_______________________________________________
Post Messages to: Dabo-users@...
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/4AF6B909.4020205@...

Re: Cursor SQL Error

by Jacek Kałucki :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Użytkownik Uwe Grauer napisał:
> Now you know that using Kinterbasdb 3.3 might be easier. ;-)
>    

Already upgraded. Thanks for point Uwe :)

--
Regards
Jacek Kałucki

_______________________________________________
Post Messages to: Dabo-users@...
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/4AF6B9C7.3010406@...

Re: Cursor SQL Error

by Ed Leafe :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Nov 8, 2009, at 4:09 AM, Jacek Kałucki wrote:

> No I didn't run any SQL statements before for this connection.
> This is the exact code: create connection, cursor, then execute query.
> I'm using PosthreSQL 8.3.7.1400.

        Can you try running this with a DatabaseActivityLog set? Start your  
app like this:

app = dabo.dApp(DatabaseActivityLog="data.log")

...and then post the contents here? If it's a big log, send it to me  
off-list.



-- Ed Leafe



_______________________________________________
Post Messages to: Dabo-users@...
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/1D03B37A-B1E3-4889-A833-24395662A136@...

Re: Cursor SQL Error

by Jacek Kałucki :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Użytkownik Ed Leafe napisał:
> Can you try running this with a DatabaseActivityLog set? Start your
> app like this:
>
> app = dabo.dApp(DatabaseActivityLog="data.log")
>
> ...and then post the contents here? If it's a big log, send it to me
> off-list.
>    

Oh, I did that before, but didn't remember about it.
Strange is, that after restarting whole machine problems gone.
Here is log content before restart:
     Database Activity Log: Sun Nov 08 13:24:45 2009: FAILED SQL: select
* from users
     Database Activity Log: Sun Nov 08 13:24:46 2009: FAILED SQL: select
*   from   limit 1
And this is after restart:
     Database Activity Log: Mon Nov 09 01:42:16 2009: SQL: select * from
users
I didn't change anything in code, which is exactly the same, but I
upgraded psycopg2
from 2.0.12 to 2.0.13 version. Could it be a reason?
But before upgrade, I worked with database with pgAdmin and with pure
psycopg2 too
and everything worked fine except Dabo.
What do you think about it?

--
Regards
Jacek Kałucki

_______________________________________________
Post Messages to: Dabo-users@...
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/4AF76A2E.1050809@...

Re: Cursor SQL Error

by Ed Leafe :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Nov 8, 2009, at 7:02 PM, Jacek Kałucki wrote:

> Oh, I did that before, but didn't remember about it.
> Strange is, that after restarting whole machine problems gone.

        That's pretty strange. It's good that the problem is gone, but now  
we'll never figure out what caused it.

> Here is log content before restart:
>     Database Activity Log: Sun Nov 08 13:24:45 2009: FAILED SQL:  
> select
> * from users
>     Database Activity Log: Sun Nov 08 13:24:46 2009: FAILED SQL:  
> select
> *   from   limit 1

        I wonder how this last query got in: it's missing the table name in  
the FROM clause.

> And this is after restart:
>     Database Activity Log: Mon Nov 09 01:42:16 2009: SQL: select *  
> from
> users
> I didn't change anything in code, which is exactly the same, but I
> upgraded psycopg2
> from 2.0.12 to 2.0.13 version. Could it be a reason?

        Possibly, but I would doubt it.

> But before upgrade, I worked with database with pgAdmin and with pure
> psycopg2 too
> and everything worked fine except Dabo.
> What do you think about it?


        It sounds like the Dabo connection was holding open a transaction,  
and needed a rollback() to clear it. If you run into this again,  
please post the log entries for it and maybe we'll find a clue.


-- Ed Leafe



_______________________________________________
Post Messages to: Dabo-users@...
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/35C9484C-0CBF-4A86-8734-454E5FDE1878@...

Re: Cursor SQL Error

by Jacek Kałucki :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Użytkownik Ed Leafe napisał:

>> Here is log content before restart:
>>      Database Activity Log: Sun Nov 08 13:24:45 2009: FAILED SQL:
>> select
>> * from users
>>      Database Activity Log: Sun Nov 08 13:24:46 2009: FAILED SQL:
>> select
>> *   from   limit 1
>>      
> I wonder how this last query got in: it's missing the table name in
> the FROM clause.
>    
>> And this is after restart:
>>      Database Activity Log: Mon Nov 09 01:42:16 2009: SQL: select *
>> from users
>>      

Another strange thing is that second query didn't appear in log after
the change.

>
> It sounds like the Dabo connection was holding open a transaction,
> and needed a rollback() to clear it. If you run into this again,
> please post the log entries for it and maybe we'll find a clue.
>    

I think, that backend should rollback open transactions automatically
when client
closes/breaks connection, so when Dabo application process ends, there
should
be no open connections and transactions. Next time I check it in network
monitor.
I hope there will be no next time with riddle like this ;-)
Thanks Ed.

--
Regards
Jacek Kałucki

_______________________________________________
Post Messages to: Dabo-users@...
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/4AF7DAF9.1060900@...