Re: [SQLObject] overriden column trouble

2007-06-12 Thread Oleg Broytmann
On Tue, Jun 12, 2007 at 09:58:53AM -0400, Stanko Petrovic wrote:
> At work we are usign pyodbc with sqlobject0.7.7 to talk to sqlserver. I am
> not sure if anybody is intrested but I can ask to post some code how to do
> it is
> preaty easy

   Please do.

Oleg.
-- 
 Oleg Broytmannhttp://phd.pp.ru/[EMAIL PROTECTED]
   Programmers don't die, they just GOSUB without RETURN.

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss


Re: [SQLObject] overriden column trouble

2007-06-12 Thread Stanko Petrovic

Thank you Oleg

I own you a beer for this!!!

At work we are usign pyodbc with sqlobject0.7.7 to talk to sqlserver. I am
not sure if anybody is intrested but I can ask to post some code how to do
it is
preaty easy, Nice thing is you can use py2exe and InnoSetup  to make a
setup.ext type of app



On 6/12/07, Oleg Broytmann <[EMAIL PROTECTED]> wrote:


On Tue, Jun 12, 2007 at 09:35:13AM -0400, Stanko Petrovic wrote:
> I am coverting code from sqlobject 0.6.1 to 0.7.7
> and in 0.6.1 they used to have
>
> self._SO_creating attribute which we do not have in 0.7.7
>
> is there anything that I can use instead of _SO_creating

  self.sqlmeta._creating

Oleg.
--
Oleg Broytmannhttp://phd.pp.ru/[EMAIL PROTECTED]
  Programmers don't die, they just GOSUB without RETURN.

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/___
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss


Re: [SQLObject] overriden column trouble

2007-06-12 Thread Oleg Broytmann
On Tue, Jun 12, 2007 at 09:35:13AM -0400, Stanko Petrovic wrote:
> I am coverting code from sqlobject 0.6.1 to 0.7.7
> and in 0.6.1 they used to have
> 
> self._SO_creating attribute which we do not have in 0.7.7
> 
> is there anything that I can use instead of _SO_creating

   self.sqlmeta._creating

Oleg.
-- 
 Oleg Broytmannhttp://phd.pp.ru/[EMAIL PROTECTED]
   Programmers don't die, they just GOSUB without RETURN.

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss


Re: [SQLObject] overriden column trouble

2007-06-12 Thread Stanko Petrovic

Thanks Oleg

I am coverting code from sqlobject 0.6.1 to 0.7.7
and in 0.6.1 they used to have

self._SO_creating attribute which we do not have in 0.7.7

is there anything that I can use instead of _SO_creating


On 6/12/07, Oleg Broytmann <[EMAIL PROTECTED]> wrote:


On Mon, Jun 11, 2007 at 04:24:11PM -0400, Stanko Petrovic wrote:
> class Testadd(so.SQLObject):
>class sqlmeta:
>style = so.MixedCaseStyle(longID=True)
>table = 'testadd'
>
>Name = so.StringCol()
>BufferSize = so.FloatCol( default = 0.0 )
>
>def _set_BufferSize(self, value):
>if value != self._SO_get_BufferSize():
>value = 1.0
>self._SO_set_BufferSize(value)
>
>def _get_BufferSize(self):
>return self._SO_get_BufferSize()
>
> t2=Testadd(Name="test6")

  You are creating a new row; the row hasn't been instered yet, so it
doesn't have an id. But before setting the new value in _set_BufferSize()
you ask the database about the previous value. How can SQLObject answer
the
question without knowing the id of the row? It cannot, hence the error:

> This fails with error main.py line 1124 in set
> raise AttributeError ..
> Testadd object has no attribute 'id' (with attribute 'BufferSize')

Oleg.
--
Oleg Broytmannhttp://phd.pp.ru/[EMAIL PROTECTED]
  Programmers don't die, they just GOSUB without RETURN.

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/___
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss


Re: [SQLObject] LEFTJOINOn and InheritableSQLObject weirdness

2007-06-12 Thread Daniel Nogradi
> > > > > > sqlobject.dberrors.OperationalError: no such column: animal.cage_id
> > > > >
> > > > >But there is "cage_id" columnm in the "animal" table
> > > >
> > > > Well, that's exactly the problem :)
> > >
> > >Are you sure this part of the problem is in SQLObject and not in
> SQLite?
> > > (There are probably other problems - inheritance was developed for
> simple
> > > use cases and hardly support joins and aggregates...)
> >
> > I only guess that the problem is with SQLObject since SQLite itself is
> > pretty reliable. But I'm getting also more and more convinced that
> > using inheritance is not a good idea, I ran into other similar
> > troubles too. So probably it's best to stay away from them.
>
> I use inheritance a lot, but I don't usually do JOINs (I just do it the OO
> way since I don't have very large sets of data) and it works very well.


Hi, can you please test the code below (if you have sqlite)? If you
use a different db, can you please change the connectionForURI to use
yours and test then? The correct output should be 5 of course.

If you don't use joins, how would you select the total number of
animals in a zoo in this example? Select (almost) everything and
filter through them in python?

Thanks a lot,
Daniel





#

from sqlobject import *
from sqlobject.inheritance import InheritableSQLObject
from sqlobject.sqlbuilder import LEFTJOINOn
from sqlobject import connectionForURI

sqlhub.processConnection = connectionForURI( 'sqlite:///:memory:', debug=True )

class named( InheritableSQLObject ):
   name = StringCol( )

class zoo( named ):
# class zoo( SQLObject ):
   # name = StringCol( )
   cages = MultipleJoin( 'cage' )

class cage( named ):
# class cage( SQLObject ):
   # name = StringCol( )
   animals = MultipleJoin( 'animal' )
   zoo = ForeignKey( 'zoo' )

class animal( named ):
# class animal( SQLObject ):
   # name = StringCol( )
   cage = ForeignKey( 'cage' )

named.createTable( )
zoo.createTable( )
cage.createTable( )
animal.createTable( )

z = zoo( name='myzoo' )

c1 = cage( name='firstcage', zoo=z )
c2 = cage( name='secondcage', zoo=z )

a11 = animal( name='tiger', cage=c1 )
a12 = animal( name='lion', cage=c1 )

a21 = animal( name='croc', cage=c2 )
a22 = animal( name='hypo', cage=c2 )
a23 = animal( name='fish', cage=c2 )

print '-'*80

joins = [ ]
joins.append( LEFTJOINOn( None, cage, animal.q.cageID==cage.q.id ) )
joins.append( LEFTJOINOn( None, zoo, cage.q.zooID==zoo.q.id ) )

print animal.select( zoo.q.name=='myzoo', join=joins ).count( )



-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss


Re: [SQLObject] overriden column trouble

2007-06-12 Thread Oleg Broytmann
On Mon, Jun 11, 2007 at 04:24:11PM -0400, Stanko Petrovic wrote:
> class Testadd(so.SQLObject):
>class sqlmeta:
>style = so.MixedCaseStyle(longID=True)
>table = 'testadd'
> 
>Name = so.StringCol()
>BufferSize = so.FloatCol( default = 0.0 )
> 
>def _set_BufferSize(self, value):
>if value != self._SO_get_BufferSize():
>value = 1.0
>self._SO_set_BufferSize(value)
> 
>def _get_BufferSize(self):
>return self._SO_get_BufferSize()
> 
> t2=Testadd(Name="test6")

   You are creating a new row; the row hasn't been instered yet, so it
doesn't have an id. But before setting the new value in _set_BufferSize()
you ask the database about the previous value. How can SQLObject answer the
question without knowing the id of the row? It cannot, hence the error:

> This fails with error main.py line 1124 in set
> raise AttributeError ..
> Testadd object has no attribute 'id' (with attribute 'BufferSize')

Oleg.
-- 
 Oleg Broytmannhttp://phd.pp.ru/[EMAIL PROTECTED]
   Programmers don't die, they just GOSUB without RETURN.

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss