Hi all, new to SQLObject, but already really enjoying it.

I'm trying to pull in an SQLObject class from an already existing
database schema, but having no success.  It would seem to be pretty
straightforward:

  import sys, os
  from sqlobject import *

  class Owners(SQLObject):
    class sqlmeta:
      table = 'Owners'
      fromDatabase = True

  def main():
    conn = connectionForURI("mysql://virtual:[EMAIL 
PROTECTED]/virtual?debug=1&debugOutput=1")
    sqlhub.processConnection = conn

    o = Owners.get(7)
    print o

  if __name__ == '__main__':
    main()

However, this results in the following traceback:

  Traceback (most recent call last):
    File "./test3.py", line 6, in ?
      class Owners(SQLObject):
    File "/usr/lib/python2.4/site-packages/sqlobject/declarative.py", line 121, 
in __new__
      cls.__classinit__(cls, new_attrs)
    File "/usr/lib/python2.4/site-packages/sqlobject/main.py", line 784, in 
__classinit__
      cls.sqlmeta.addColumnsFromDatabase()
    File "/usr/lib/python2.4/site-packages/sqlobject/main.py", line 441, in 
addColumnsFromDatabase
      conn = connection or soClass._connection
    File "/usr/lib/python2.4/site-packages/sqlobject/dbconnection.py", line 
973, in __get__
      return self.getConnection()
    File "/usr/lib/python2.4/site-packages/sqlobject/dbconnection.py", line 
985, in getConnection
      raise AttributeError(
  AttributeError: No connection has been defined for this thread or process

If I go ahead and just define the class myself (it's a simple one with
only two columns), everything works fine and I can retrieve data as one
would expect.

Is there something more I need to do to attach a connection to my
class?  The above appears to be in line with most of the examples I've
come across.

This is with SQLObject 0.9.2 and MySQLdb 1.2.1.

Thanks!
Ray

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to