Oleg Broytman | 1 Mar 2012 17:07
X-Face
Favicon
Gravatar

SQLObject 1.1.5

Hello!

I'm pleased to announce version 1.1.5, a bugfix release of branch
1.1 of SQLObject.

What is SQLObject
=================

SQLObject is an object-relational mapper.  Your database tables are described
as classes, and rows are instances of those classes.  SQLObject is meant to be
easy to use and quick to get started with.

SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite,
Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB).

Where is SQLObject
==================

Site:
http://sqlobject.org

Development:
http://sqlobject.org/devel/

Mailing list:
https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss

Archives:
http://news.gmane.org/gmane.comp.python.sqlobject

(Continue reading)

Oleg Broytman | 1 Mar 2012 17:07
X-Face
Favicon
Gravatar

SQLObject 1.2.2

Hello!

I'm pleased to announce version 1.2.2, a bugfix release of branch
1.2 of SQLObject.

What is SQLObject
=================

SQLObject is an object-relational mapper.  Your database tables are described
as classes, and rows are instances of those classes.  SQLObject is meant to be
easy to use and quick to get started with.

SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite,
Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB).

Where is SQLObject
==================

Site:
http://sqlobject.org

Development:
http://sqlobject.org/devel/

Mailing list:
https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss

Archives:
http://news.gmane.org/gmane.comp.python.sqlobject

(Continue reading)

Hans Georg Schaathun | 18 Mar 2012 18:50

The autocommit bug with psycopg2

Hi,

sorry if this is an old topic, but I did not find any list
archive.  I just took up using SQLObject a few weeks ago;
very convenient.

I wonder if anyone has experience with a bug where the
the postgress connection attempts to call a boolean
value (autocommit) as a method.  (Call stack is cut in below.)
It is not a new problem, I found it reported here as well:
http://stackoverflow.com/questions/6374121/python-why-does-sqlobject-fail-in-conn-autocommit1

What is odd is that my code works fine on Ubuntu 10.4 with a connection
to localhost.  When I run the same code on Ubuntu 10.10 with a remote
server, it fails.  I am not sure if the difference is with the
remoteness or the software version ... So far I have tried to make do
 with the standard ubuntu packages for sqlobject and postgres.

Does anyone know if this problem has been resolved in some recent 
version of sqlobject/psycopg?  Or if there is a known workaround?
I do observe that the URL below suggests what looks like a 
downgrading of psycopg2, which I won't do if upgrading is an option :-)

My call stack is:
  File "/home/georg/git/pysteg/src/pysteg/sql/tables.py", line 346, in
getJob
    trans = conn.transaction()
  File "/usr/lib/pymodules/python2.7/sqlobject/dbconnection.py", line
400, in transaction
    return Transaction(self)
(Continue reading)

Oleg Broytman | 18 Mar 2012 19:10
X-Face
Favicon
Gravatar

Re: The autocommit bug with psycopg2

On Sun, Mar 18, 2012 at 06:50:07PM +0100, Hans Georg Schaathun wrote:
> sorry if this is an old topic, but I did not find any list
> archive.

   Archives are listed at http://sqlobject.org/community.html

> I just took up using SQLObject a few weeks ago;
> very convenient.
> 
>   File
> "/usr/lib/pymodules/python2.7/sqlobject/postgres/pgconnection.py", line
> 133, in makeConnection
>     conn.autocommit(1)
> TypeError: 'bool' object is not callable

   The bug has been fixed in SQLObject 1.2. Consider upgrading to a
later version.

Oleg.
--

-- 
     Oleg Broytman            http://phdru.name/            phd <at> phdru.name
           Programmers don't die, they just GOSUB without RETURN.

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
Hans Georg Schaathun | 18 Mar 2012 20:00

Re: The autocommit bug with psycopg2

>    Archives are listed at http://sqlobject.org/community.html

Indeed.  Sorry.  I misread that sentence and thought it referred
to a different list.  Silly me.

>    The bug has been fixed in SQLObject 1.2. Consider upgrading to a
> later version.

Brilliant.  Thank you very much.
It is either that, or just pray patiently that
Ubuntu will upgrade it in the next release next month :-)

:-- George

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
Jeremy Hoyle | 26 Mar 2012 01:56
Picon

SqlObject Sqlmeta fromDatabase problem

I have a problem while trying to use the "fromDatabase = True" option in sqlmeta. Any time I enable this. it gives me the connection error below. Is there another attribute I need to do before doing this? I saw another thread with this problem but the solution was enable the connection before the class which I have done.

from sqlobject import *

class Companys(SQLObject):
     def __init__(self):
        connection_string = 'mysql://user:password <at> 127.0.0.1:3306/pySMS'
        conn = connectionForURI(connection_string,debug = True,autoCommit = True)
        trans = conn.transaction()
        sqlhub.processConnection = conn
        Company.createTable(ifNotExists = True, connection=conn)
        Company._connection.debug = True
    
class Company(SQLObject):

    class sqlmeta:
       fromDatabase = True
       lazyUpdate = True
       cacheValues = True
 
    Company_Name = StringCol(length = 256, default = None)
    Company_Address = StringCol(length = 256, default = None)
    Company_Phone = StringCol(length = 256, default = None)

Traceback (most recent call last):
  File "C:\Pysoft\Software\SMS Development\tests\test0.py", line 5, in <module>
    from pySMS import Companys
  File "C:\Pysoft\Software\SMS Development\pySMS\__init__.py", line 1, in <module>
    from Company import Companys
  File "C:\Pysoft\Software\SMS Development\pySMS\Company.py", line 138, in <module>
    class Company(SQLObject):
  File "C:\Python27\lib\site-packages\sqlobject-1.2.1-py2.7.egg\sqlobject\declarative.py", line 92, in __new__
    cls.__classinit__(cls, new_attrs)
  File "C:\Python27\lib\site-packages\sqlobject-1.2.1-py2.7.egg\sqlobject\main.py", line 789, in __classinit__
    sqlmeta.addColumnsFromDatabase()
  File "C:\Python27\lib\site-packages\sqlobject-1.2.1-py2.7.egg\sqlobject\main.py", line 441, in addColumnsFromDatabase
    conn = connection or soClass._connection
  File "C:\Python27\lib\site-packages\sqlobject-1.2.1-py2.7.egg\sqlobject\dbconnection.py", line 902, in __get__
    return self.getConnection()
  File "C:\Python27\lib\site-packages\sqlobject-1.2.1-py2.7.egg\sqlobject\dbconnection.py", line 915, in getConnection
    "No connection has been defined for this thread "
AttributeError: No connection has been defined for this thread or process

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
Oleg Broytman | 26 Mar 2012 10:52
X-Face
Favicon
Gravatar

Re: SqlObject Sqlmeta fromDatabase problem

Hi!

On Sun, Mar 25, 2012 at 06:56:32PM -0500, Jeremy Hoyle wrote:
> I have a problem while trying to use the "fromDatabase = True" option in
> sqlmeta. Any time I enable this. it gives me the connection error below. Is
> there another attribute I need to do before doing this? I saw another
> thread with this problem but the solution was enable the connection before
> the class which I have done.
> 
> from sqlobject import *
> 
> class Companys(SQLObject):
>      def __init__(self):
>         connection_string = 'mysql://user:password <at> 127.0.0.1:3306/pySMS'
>         conn = connectionForURI(connection_string,debug = True,autoCommit =
> True)
>         trans = conn.transaction()
>         sqlhub.processConnection = conn
>         Company.createTable(ifNotExists = True, connection=conn)
>         Company._connection.debug = True

   A number of problems here.
1. The connection is created in Companys.__init__ which is not called,
at least it is not called when SQLObject's metaclass processes
fromDatabase. fromDatabase requires an open connection.
2. A transaction is opened but never used. Transaction (trans, in your
case) has to be used instead of connection (in sqlhub, or in every
SQLObject call that accepts connection).

> class Company(SQLObject):
> 
>     class sqlmeta:
>        fromDatabase = True
>        lazyUpdate = True
>        cacheValues = True
> 
>     Company_Name = StringCol(length = 256, default = None)
>     Company_Address = StringCol(length = 256, default = None)
>     Company_Phone = StringCol(length = 256, default = None)
> 
> Traceback (most recent call last):
>   File "C:\Pysoft\Software\SMS Development\tests\test0.py", line 5, in
> <module>
>     from pySMS import Companys
>   File "C:\Pysoft\Software\SMS Development\pySMS\__init__.py", line 1, in
> <module>
>     from Company import Companys
>   File "C:\Pysoft\Software\SMS Development\pySMS\Company.py", line 138, in
> <module>
>     class Company(SQLObject):
>   File
> "C:\Python27\lib\site-packages\sqlobject-1.2.1-py2.7.egg\sqlobject\declarative.py",
> line 92, in __new__
>     cls.__classinit__(cls, new_attrs)
>   File
> "C:\Python27\lib\site-packages\sqlobject-1.2.1-py2.7.egg\sqlobject\main.py",
> line 789, in __classinit__
>     sqlmeta.addColumnsFromDatabase()
>   File
> "C:\Python27\lib\site-packages\sqlobject-1.2.1-py2.7.egg\sqlobject\main.py",
> line 441, in addColumnsFromDatabase
>     conn = connection or soClass._connection
>   File
> "C:\Python27\lib\site-packages\sqlobject-1.2.1-py2.7.egg\sqlobject\dbconnection.py",
> line 902, in __get__
>     return self.getConnection()
>   File
> "C:\Python27\lib\site-packages\sqlobject-1.2.1-py2.7.egg\sqlobject\dbconnection.py",
> line 915, in getConnection
>     "No connection has been defined for this thread "
> AttributeError: No connection has been defined for this thread or process

Oleg.
--

-- 
     Oleg Broytman            http://phdru.name/            phd <at> phdru.name
           Programmers don't die, they just GOSUB without RETURN.

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
Jeremy Hoyle | 26 Mar 2012 11:30
Picon

Re: SqlObject Sqlmeta fromDatabase problem

Thank you for your response. I'm sorry for not including these details for I have been struggling with this problem for sometime. These suggestions have been tried or already implemented with the same result. Pleased let me know if you have any other suggestions.


def __init__(self):
    connection_string = 'mysql://user:password <at> 127.0.0.1:3306/pySMS'
    conn = connectionForURI(connection_string,debug = True,autoCommit = True)
    trans = conn.transaction()
    sqlhub.processConnection = conn
    Company.createTable(ifNotExists = True, connection=trans)

test0.py file

import sys
from sqlobject import *
from pySMS import Companys

if __name__ == "__main__":

    pysoft = Companys()


Traceback (most recent call last):
  File "C:\Pysoft\Software\SMS Development\tests\test0.py", line 5, in <module>
    from pySMS import Companys
  File "C:\Pysoft\Software\SMS Development\pySMS\__init__.py", line 1, in <module>
    from Company import Companys
  File "C:\Pysoft\Software\SMS Development\pySMS\Company.py", line 137, in <module>
    class Company(SQLObject):
  File "C:\Python27\lib\site-packages\sqlobject-1.2.1-py2.7.egg\sqlobject\declarative.py", line 92, in __new__
    cls.__classinit__(cls, new_attrs)
  File "C:\Python27\lib\site-packages\sqlobject-1.2.1-py2.7.egg\sqlobject\main.py", line 789, in __classinit__
    sqlmeta.addColumnsFromDatabase()
  File "C:\Python27\lib\site-packages\sqlobject-1.2.1-py2.7.egg\sqlobject\main.py", line 441, in addColumnsFromDatabase
    conn = connection or soClass._connection
  File "C:\Python27\lib\site-packages\sqlobject-1.2.1-py2.7.egg\sqlobject\dbconnection.py", line 902, in __get__
    return self.getConnection()
  File "C:\Python27\lib\site-packages\sqlobject-1.2.1-py2.7.egg\sqlobject\dbconnection.py", line 915, in getConnection
    "No connection has been defined for this thread "
AttributeError: No connection has been defined for this thread or process



On Mon, Mar 26, 2012 at 3:52 AM, Oleg Broytman <phd <at> phdru.name> wrote:
Hi!

On Sun, Mar 25, 2012 at 06:56:32PM -0500, Jeremy Hoyle wrote:
> I have a problem while trying to use the "fromDatabase = True" option in
> sqlmeta. Any time I enable this. it gives me the connection error below. Is
> there another attribute I need to do before doing this? I saw another
> thread with this problem but the solution was enable the connection before
> the class which I have done.
>
> from sqlobject import *
>
> class Companys(SQLObject):
>      def __init__(self):
>         connection_string = 'mysql://user:password <at> 127.0.0.1:3306/pySMS'
>         conn = connectionForURI(connection_string,debug = True,autoCommit =
> True)
>         trans = conn.transaction()
>         sqlhub.processConnection = conn
>         Company.createTable(ifNotExists = True, connection=conn)
>         Company._connection.debug = True

  A number of problems here.
1. The connection is created in Companys.__init__ which is not called,
at least it is not called when SQLObject's metaclass processes
fromDatabase. fromDatabase requires an open connection.
2. A transaction is opened but never used. Transaction (trans, in your
case) has to be used instead of connection (in sqlhub, or in every
SQLObject call that accepts connection).

> class Company(SQLObject):
>
>     class sqlmeta:
>        fromDatabase = True
>        lazyUpdate = True
>        cacheValues = True
>
>     Company_Name = StringCol(length = 256, default = None)
>     Company_Address = StringCol(length = 256, default = None)
>     Company_Phone = StringCol(length = 256, default = None)
>
> Traceback (most recent call last):
>   File "C:\Pysoft\Software\SMS Development\tests\test0.py", line 5, in
> <module>
>     from pySMS import Companys
>   File "C:\Pysoft\Software\SMS Development\pySMS\__init__.py", line 1, in
> <module>
>     from Company import Companys
>   File "C:\Pysoft\Software\SMS Development\pySMS\Company.py", line 138, in
> <module>
>     class Company(SQLObject):
>   File
> "C:\Python27\lib\site-packages\sqlobject-1.2.1-py2.7.egg\sqlobject\declarative.py",
> line 92, in __new__
>     cls.__classinit__(cls, new_attrs)
>   File
> "C:\Python27\lib\site-packages\sqlobject-1.2.1-py2.7.egg\sqlobject\main.py",
> line 789, in __classinit__
>     sqlmeta.addColumnsFromDatabase()
>   File
> "C:\Python27\lib\site-packages\sqlobject-1.2.1-py2.7.egg\sqlobject\main.py",
> line 441, in addColumnsFromDatabase
>     conn = connection or soClass._connection
>   File
> "C:\Python27\lib\site-packages\sqlobject-1.2.1-py2.7.egg\sqlobject\dbconnection.py",
> line 902, in __get__
>     return self.getConnection()
>   File
> "C:\Python27\lib\site-packages\sqlobject-1.2.1-py2.7.egg\sqlobject\dbconnection.py",
> line 915, in getConnection
>     "No connection has been defined for this thread "
> AttributeError: No connection has been defined for this thread or process

Oleg.
--
    Oleg Broytman            http://phdru.name/            phd <at> phdru.name
          Programmers don't die, they just GOSUB without RETURN.

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
Oleg Broytman | 26 Mar 2012 11:42
X-Face
Favicon
Gravatar

Re: SqlObject Sqlmeta fromDatabase problem

On Mon, Mar 26, 2012 at 04:30:26AM -0500, Jeremy Hoyle wrote:
> Thank you for your response. I'm sorry for not including these details for
> I have been struggling with this problem for sometime. These suggestions
> have been tried or already implemented with the same result. Pleased let me
> know if you have any other suggestions.
> 
> def __init__(self):
>     connection_string = 'mysql://user:password <at> 127.0.0.1:3306/pySMS'
>     conn = connectionForURI(connection_string,debug = True,autoCommit =
> True)
>     trans = conn.transaction()
>     sqlhub.processConnection = conn
>     Company.createTable(ifNotExists = True, connection=trans)

   What's that? A global function or a method? Where it's called?

> test0.py file
> 
> import sys
> from sqlobject import *
> from pySMS import Companys
> 
> if __name__ == "__main__":
> 
>     pysoft = Companys()
> 
> 
> Traceback (most recent call last):
>   File "C:\Pysoft\Software\SMS Development\tests\test0.py", line 5, in
> <module>
>     from pySMS import Companys
>   File "C:\Pysoft\Software\SMS Development\pySMS\__init__.py", line 1, in
> <module>
>     from Company import Companys
>   File "C:\Pysoft\Software\SMS Development\pySMS\Company.py", line 137, in
> <module>
>     class Company(SQLObject):
>   File
> "C:\Python27\lib\site-packages\sqlobject-1.2.1-py2.7.egg\sqlobject\declarative.py",
> line 92, in __new__
>     cls.__classinit__(cls, new_attrs)
>   File
> "C:\Python27\lib\site-packages\sqlobject-1.2.1-py2.7.egg\sqlobject\main.py",
> line 789, in __classinit__
>     sqlmeta.addColumnsFromDatabase()
>   File
> "C:\Python27\lib\site-packages\sqlobject-1.2.1-py2.7.egg\sqlobject\main.py",
> line 441, in addColumnsFromDatabase
>     conn = connection or soClass._connection
>   File
> "C:\Python27\lib\site-packages\sqlobject-1.2.1-py2.7.egg\sqlobject\dbconnection.py",
> line 902, in __get__
>     return self.getConnection()
>   File
> "C:\Python27\lib\site-packages\sqlobject-1.2.1-py2.7.egg\sqlobject\dbconnection.py",
> line 915, in getConnection
>     "No connection has been defined for this thread "
> AttributeError: No connection has been defined for this thread or process

   The same problem - no connection has been defined. The code tried to
open a connection in Companys.__init__, but Companys is an SQLObject's
table and thus requires an open connection.
   Open a connection outside of SQLObject's initialization.

Oleg.
--

-- 
     Oleg Broytman            http://phdru.name/            phd <at> phdru.name
           Programmers don't die, they just GOSUB without RETURN.

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
Jeremy Hoyle | 26 Mar 2012 14:42
Picon

Re: SqlObject Sqlmeta fromDatabase problem

 What's that? A global function or a method? Where it's called? 

It is the Companys class. It is called from my test0.py file. See below.

 The same problem - no connection has been defined. The code tried to
open a connection in Companys.__init__, but Companys is an SQLObject's
table and thus requires an open connection.
 Open a connection outside of SQLObject's initialization.

Companys is not a sqlobject table. Company is a sqlobject table. Sorry for the confusion. I chose poor naming. Do I not need to extend the SQLObject in Companys? See all of them below.

Company.py file 
class Company(SQLObject):
    class sqlmeta:
       fromDatabase = True
       lazyUpdate = True
       cacheValues = True
   Company_Name = StringCol(length = 256, default = None)
   Company_Address = StringCol(length = 256, default = None)
   Company_Phone = StringCol(length = 256, default = None)

class Companys(SQLObject):
     def __init__(self):
         connection_string = 'mysql://user:password <at> 127.0.0.1:3306/pySMS'
         conn = connectionForURI(connection_string,debug = True,autoCommit =True)
         trans = conn.transaction()
         sqlhub.processConnection = conn
         Company.createTable(ifNotExists = True, connection=trans)

 test0.py file

 import sys
 from sqlobject import *
 from pySMS import Companys

 if __name__ == "__main__":

     pysoft = Companys()

On Mon, Mar 26, 2012 at 4:42 AM, Oleg Broytman <phd <at> phdru.name> wrote:
On Mon, Mar 26, 2012 at 04:30:26AM -0500, Jeremy Hoyle wrote:
> Thank you for your response. I'm sorry for not including these details for
> I have been struggling with this problem for sometime. These suggestions
> have been tried or already implemented with the same result. Pleased let me
> know if you have any other suggestions.
>
> def __init__(self):
>     connection_string = 'mysql://user:password <at> 127.0.0.1:3306/pySMS'
>     conn = connectionForURI(connection_string,debug = True,autoCommit =
> True)
>     trans = conn.transaction()
>     sqlhub.processConnection = conn
>     Company.createTable(ifNotExists = True, connection=trans)

  What's that? A global function or a method? Where it's called?

> test0.py file
>
> import sys
> from sqlobject import *
> from pySMS import Companys
>
> if __name__ == "__main__":
>
>     pysoft = Companys()
>
>
> Traceback (most recent call last):
>   File "C:\Pysoft\Software\SMS Development\tests\test0.py", line 5, in
> <module>
>     from pySMS import Companys
>   File "C:\Pysoft\Software\SMS Development\pySMS\__init__.py", line 1, in
> <module>
>     from Company import Companys
>   File "C:\Pysoft\Software\SMS Development\pySMS\Company.py", line 137, in
> <module>
>     class Company(SQLObject):
>   File
> "C:\Python27\lib\site-packages\sqlobject-1.2.1-py2.7.egg\sqlobject\declarative.py",
> line 92, in __new__
>     cls.__classinit__(cls, new_attrs)
>   File
> "C:\Python27\lib\site-packages\sqlobject-1.2.1-py2.7.egg\sqlobject\main.py",
> line 789, in __classinit__
>     sqlmeta.addColumnsFromDatabase()
>   File
> "C:\Python27\lib\site-packages\sqlobject-1.2.1-py2.7.egg\sqlobject\main.py",
> line 441, in addColumnsFromDatabase
>     conn = connection or soClass._connection
>   File
> "C:\Python27\lib\site-packages\sqlobject-1.2.1-py2.7.egg\sqlobject\dbconnection.py",
> line 902, in __get__
>     return self.getConnection()
>   File
> "C:\Python27\lib\site-packages\sqlobject-1.2.1-py2.7.egg\sqlobject\dbconnection.py",
> line 915, in getConnection
>     "No connection has been defined for this thread "
> AttributeError: No connection has been defined for this thread or process

  The same problem - no connection has been defined. The code tried to
open a connection in Companys.__init__, but Companys is an SQLObject's
table and thus requires an open connection.
  Open a connection outside of SQLObject's initialization.

Oleg.
--
    Oleg Broytman            http://phdru.name/            phd <at> phdru.name
          Programmers don't die, they just GOSUB without RETURN.

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Gmane