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@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 <p...@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@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/ p...@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@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@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss