Ansel Halliburton | 1 Mar 04:11
Picon

InheritableSQLObject exception - am I doing something wrong, or is it a bug?

Hello!

I'm having some difficulty with inheritance.  Specifically, I'm
getting an AttributeError exception at line 348 of inheritance/
__init__.py (in InheritableSQLObject._create()) of SQLObject 0.8.
This happens when I try to instantiate my AND class, which inherits
from a class called Operator.  Interestingly, in the DB, Operator's
table has a row, with id=1 and child_name=AND.

Here's the stack trace:

   File "/Users/anseljh/pyple/src/pyple.py", line 279, in __main__
     andtf = AND(params=[True, False])
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/
python2.4/site-packages/SQLObject-0.8.0-py2.4.egg/sqlobject/
declarative.py", line 94, in _wrapper
     return fn(self, *args, **kwargs)
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/
python2.4/site-packages/SQLObject-0.8.0-py2.4.egg/sqlobject/main.py",
line 1231, in __init__
     self._create(id, **kw)
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/
python2.4/site-packages/SQLObject-0.8.0-py2.4.egg/sqlobject/
inheritance/__init__.py", line 348, in _create
     id = self._parent.id
AttributeError: 'Operator' object has no attribute 'id'

Here are the class definitions:

class Operator(InheritableSQLObject):
(Continue reading)

Oleg Broytmann | 1 Mar 09:44
X-Face
Picon
Favicon

Re: InheritableSQLObject exception - am I doing something wrong, or is it a bug?

Hello!

On Wed, Feb 28, 2007 at 07:11:20PM -0800, Ansel Halliburton wrote:
> My full code is at:
> http://pyple.svn.sourceforge.net/viewvc/pyple/src/pyple.py?
> revision=16&view=markup

   I will look at it when I could find time.

> P.S. the stack trace also includes a bunch of DeprecationWarnings as
> well, shown below:
> 
> DeprecationWarning: Use of this attribute should be replaced
> with .sqlmeta.addColumn

   The warning clearly explains what and where is wrong and how to fix
your program, right?

Oleg.
--

-- 
     Oleg Broytmann            http://phd.pp.ru/            phd <at> phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Oleg Broytmann | 1 Mar 19:29
X-Face
Picon
Favicon

Re: InheritableSQLObject exception - am I doing something wrong, or is it a bug?

On Wed, Feb 28, 2007 at 07:11:20PM -0800, Ansel Halliburton wrote:
> AttributeError: 'Operator' object has no attribute 'id'

   You've forgotten to call superclass' _init():

class Operator(InheritableSQLObject):

  parameters = MultipleJoin('Parameter')

  #def __init__(self, parameters):
  def _init(self, *args, **kw):
    InheritableSQLObject._init(self, *args, **kw)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Oleg.
--

-- 
     Oleg Broytmann            http://phd.pp.ru/            phd <at> phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Picon

newbie question wrt errno 150

Hi all, I have been trying to resolve an error that appears when I try to do the following:

------------------------------------------------------------------------------------------------
from sqlobject import *
connection_string = 'mysql://root:password <at> localhost/kway'
connection = connectionForURI(connection_string)
sqlhub.processConnection = connection

class  Contact(SQLObject):
    name=StringCol()
    surname=StringCol()
   
class Person(SQLObject):
    name=StringCol()
    surname=StringCol()
    tel=StringCol(default=None)
    mobile=StringCol(default=None)
    fax=StringCol(default=None)
    email=StringCol(default=None)
    father=StringCol(default=None)
    mother=StringCol(default=None)
    adt=StringCol(default=None)
    afm=StringCol(default=None)
    contact=ForeignKey('Contact')
   
class Address(SQLObject):
    street=StringCol()
    number=StringCol()
    city=StringCol()
    zip=StringCol(default=None)
    person=ForeignKey('Person')

--------------------------------------------------------------------------------------------------------------------------------
When I try Contact.createTable() everything is OK.
But when I subsequently try Person.createTable() I get the following error (the same happens with Address.createTable() :

Traceback (most recent call last):
  File "<input>", line 1, in ?
  File "c:\python24\lib\site-packages\SQLObject-0.8.0-py2.4.egg\sqlobject\main.py", line 1394, in createTable
    conn.query(constraint)
  File "c:\python24\lib\site-packages\SQLObject-0.8.0-py2.4.egg\sqlobject\dbconnection.py ", line 316, in query
    return self._runWithConnection(self._query, s)
  File "c:\python24\lib\site-packages\SQLObject-0.8.0-py2.4.egg\sqlobject\dbconnection.py", line 230, in _runWithConnection
    val = meth(conn, *args)
  File "c:\python24\lib\site-packages\SQLObject-0.8.0-py2.4.egg\sqlobject\dbconnection.py", line 313, in _query
    self._executeRetry(conn, conn.cursor(), s)
  File "c:\python24\lib\site-packages\SQLObject- 0.8.0-py2.4.egg\sqlobject\mysql\mysqlconnection.py", line 109, in _executeRetry
    raise OperationalError(ErrorMessage(e))
OperationalError: Can't create table 'kway.#sql-28c_4' (errno: 150)


But when I check the created tables, I find out that the tables are actually created.
After some investigation, I found out that this is  due to the ForeignKey declaration (If I comment it out, the error doesn't appear).
I have tried a lot to resolve this error to no avail. Any help will be greatly appreciated!!!!
(I am running winXP sp2, mysql5.1.16b, python2.4 and SQLObject 0.8.0)

thanks, 
Nik

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
Oleg Broytmann | 2 Mar 17:51
X-Face
Picon
Favicon

Re: newbie question wrt errno 150

On Fri, Mar 02, 2007 at 05:12:22PM +0200, Nikolas Psaroudakis wrote:
> ------------------------------------------------------------------------------------------------
> from sqlobject import *
> connection_string = 'mysql://root:password <at> localhost/kway'
> connection = connectionForURI(connection_string)
> sqlhub.processConnection = connection
> 
> class  Contact(SQLObject):
>    name=StringCol()
>    surname=StringCol()
> 
> class Person(SQLObject):
>    name=StringCol()
>    surname=StringCol()
>    tel=StringCol(default=None)
>    mobile=StringCol(default=None)
>    fax=StringCol(default=None)
>    email=StringCol(default=None)
>    father=StringCol(default=None)
>    mother=StringCol(default=None)
>    adt=StringCol(default=None)
>    afm=StringCol(default=None)
>    contact=ForeignKey('Contact')
> 
> class Address(SQLObject):
>    street=StringCol()
>    number=StringCol()
>    city=StringCol()
>    zip=StringCol(default=None)
>    person=ForeignKey('Person')
> 
> --------------------------------------------------------------------------------------------------------------------------------
> When I try Contact.createTable() everything is OK.
> But when I subsequently try Person.createTable() I get the following error

   The program (including three .createTables() calls) works for me on
SQLite and Postgres, with SQLObject 0.7.3 and 0.8.

Oleg.
--

-- 
     Oleg Broytmann            http://phd.pp.ru/            phd <at> phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Simon Robins | 2 Mar 20:10

Approach to large joins

I've been using the basic SQLObject APIs  very happily for the last  
year. Thanks for all the hard work.

I have a question as to what is the best approach to the following -  
I want to do a join across multiple tables potentially returning lots  
of rows. I do this with MyClass.select which gives me the attributes  
for MyClass. If I want to report the cols of the other tables I have  
to follow the joins I've set up in my classes, while this works fine  
it's not very efficient because as far as I can see another query  
happens every time I use one of these pre-set up joins.

I know I can use a raw query in these instances but I would then miss  
out on my customised columns and object oriented approach.

Is there some sort of way of having a composite object which contains  
all the classes I wanted in the join? Is there some other approach  
I've missed entirely? I noticed something relevant in the SQLBuilder  
& Views thread from Johan Dahlin a few weeks ago is that what I  
should be looking at?

On another vaguely related question - is there a proper way to  
execute a (sub)query built with sqlobject.sqbuilder.Select  
standalone. I can sometimes get a str representation and pass that to  
queryAll but not always...

Cheers.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Oleg Broytmann | 2 Mar 20:35
X-Face
Picon
Favicon

Re: Approach to large joins

On Fri, Mar 02, 2007 at 09:10:29PM +0200, Simon Robins wrote:
> Is there some sort of way of having a composite object which contains  
> all the classes I wanted in the join?

   There is no. May be you want a VIEW, if your DB supports them? A VIEW
from the point of SQLObject is just another table. There is some redundancy
- you have to declare the table in your program.

Oleg.
--

-- 
     Oleg Broytmann            http://phd.pp.ru/            phd <at> phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Peter Butler | 3 Mar 03:54
Favicon

Re: Intermediate tables not being created for RelatedJoin


> To allow SQLObject to create all tables you have to create RelatedJoins
> in both direction. See the modified program and its output below. Do they
> look right? I thjink all atbles are created now.
>   
Thanks Oleg, this works fine now.  Can I submit a documentation patch so 
that this is included in the docs?

Cheers

Peter

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Oleg Broytmann | 3 Mar 08:14
X-Face
Picon
Favicon

Re: Intermediate tables not being created for RelatedJoin

On Sat, Mar 03, 2007 at 10:54:06AM +0800, Peter Butler wrote:
> Can I submit a documentation patch so 
> that this is included in the docs?

   But of course!

Oleg.
--

-- 
     Oleg Broytmann            http://phd.pp.ru/            phd <at> phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Oleg Broytmann | 3 Mar 10:53
X-Face
Picon
Favicon

Re: Regression in SQLObject 0.8.0 using MySQL

Hello!

On Sat, Feb 24, 2007 at 12:44:42AM +0100, Dr. Markus Gritsch wrote:
> the following simple script fails to run when using SQLObject 0.8.0.
> It works fine when using SQLObject 0.7.3.
> 
> ---
> 
> from sqlobject import *
> 
> sqlhub.processConnection = connectionForURI('mysql://markus <at> localhost/test')

   Can you set the debugging flag

sqlhub.processConnection = connectionForURI('mysql://markus <at> localhost/test?debug=1')

   and show the entire output?

> class Person(SQLObject):
>    name = StringCol()
> 
> class Shortcut(SQLObject):
>    person = ForeignKey('Person')
> 
> Person.dropTable(ifExists=True)
> Person.createTable(ifNotExists=True)
> 
> Shortcut.dropTable(ifExists=True)
> Shortcut.createTable(ifNotExists=True)
> 
> ---
> 
> Traceback (most recent call last):
>  File "0.8.py", line 15, in <module>
>    Shortcut.createTable(ifNotExists=True)
>  File 
>  "c:\python25\lib\site-packages\sqlobject-0.8.0-py2.5.egg\sqlobject\main.py",
> line 1394, in createTable
>    conn.query(constraint)
>  File 
>  "c:\python25\lib\site-packages\sqlobject-0.8.0-py2.5.egg\sqlobject\dbconnection.py",
> line 316, in query
>    return self._runWithConnection(self._query, s)
>  File 
>  "c:\python25\lib\site-packages\sqlobject-0.8.0-py2.5.egg\sqlobject\dbconnection.py",
> line 230, in _runWithConnection
>    val = meth(conn, *args)
>  File 
>  "c:\python25\lib\site-packages\sqlobject-0.8.0-py2.5.egg\sqlobject\dbconnection.py",
> line 313, in _query
>    self._executeRetry(conn, conn.cursor(), s)
>  File 
>  "c:\python25\lib\site-packages\sqlobject-0.8.0-py2.5.egg\sqlobject\mysql\mysqlconnection.py",
> line 109, in _executeRetry
>    raise OperationalError(ErrorMessage(e))
> sqlobject.dberrors.OperationalError: Can't create table
> '.\test\#sql-2b4_b6.frm' (errno: 150)
Oleg.
--

-- 
     Oleg Broytmann            http://phd.pp.ru/            phd <at> phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

Gmane