Re: SqlObject Sqlmeta fromDatabase problem

Jeremy Hoyle <[email protected]>
Newsgroups gmane.comp.python.sqlobject
Message-ID <CAJPMzeJYJedgw=3Ue3-iRZxy2gFB_o94Efk1zb9vvKemXuxdqA@mail.gmail.com>
Sorry.. the previous post was in error.
Thank you for your help but although I am not receiving any errors. The
 fromDatabase boolean doesn't seem to be performing its stated function.It
does not update the database when i enter a new column in the database.

fromDatabase:A boolean (default false). If true, then on class creation the
database will be queried for the table's columns, and any missing columns
(possible all columns) will be added automatically.
I started with these
class Company(SQLObject):
class sqlmeta:
        fromDatabase = True
        lazyUpdate = False
        cacheValues = True
    Company_Name = StringCol(length = 256, default = None)
    Company_Address = StringCol(length = 256, default = None)
    Company_Phone = StringCol(length = 256, default = None)

Added
class Company(SQLObject):
class sqlmeta:
        fromDatabase = True
        lazyUpdate = False
        cacheValues = True
    Company_Name = StringCol(length = 256, default = None)
    Company_Address = StringCol(length = 256, default = None)
    Company_Phone = StringCol(length = 256, default = None)
    *Company_Number = StringCol(length = 256, default = None)*

class Companys():
    def __init__(self):
         Company.createTable(ifNotExists = True, connection=conn)

Output:>>
 2/QueryAll:  SHOW COLUMNS FROM store
 2/QueryAll:  SHOW COLUMNS FROM company
 2/Query   :  DESCRIBE company
 2/Query   :  DESCRIBE store

On Mon, Mar 26, 2012 at 7:55 PM, Jeremy Hoyle <[email protected]>wrote:

> Thank you for your help but although I am not receiving any errors. The
>  fromDatabase boolean doesn't seem to be performing its stated function.
>
> fromDatabase: A boolean (default false). If true, then on class creation
> the database will be queried for the table's columns, and any missing
> columns (possible all columns) will be added automatically.
> I started with these
> class Company(SQLObject):
> class sqlmeta:
>         fromDatabase = True
>         lazyUpdate = False
>         cacheValues = True
>     Company_Name = StringCol(length = 256, default = None)
>     Company_Address = StringCol(length = 256, default = None)
>     Company_Phone = StringCol(length = 256, default = None)
>
> Added
> class Company(SQLObject):
> class sqlmeta:
>         fromDatabase = True
>         lazyUpdate = False
>         cacheValues = True
>     Company_Name = StringCol(length = 256, default = None)
>     Company_Address = StringCol(length = 256, default = None)
>     Company_Phone = StringCol(length = 256, default = None)
>  Company_Phone = StringCol(length = 256, default = None)
> On Mon, Mar 26, 2012 at 8:16 AM, Jeremy Hoyle <[email protected]>wrote:
>
>> Ok. I got it. I just defined the connection above and outside the
>> Companys and Company classes. Thanks for your help.
>>
>> Jeremy
>>
>>
>> On Mon, Mar 26, 2012 at 8:05 AM, Oleg Broytman <[email protected]> wrote:
>>
>>> On Mon, Mar 26, 2012 at 07:59:39AM -0500, Jeremy Hoyle wrote:
>>> >   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
>>>
>>>    Here is the problem now - Company (and Companys) is imported before
>>> a connection is created. You have to open a connection before the class
>>> Company is created (i.e., before the module is imported).
>>>
>>> Oleg.
>>> --
>>>     Oleg Broytman            http://phdru.name/
>>> [email protected]
>>>           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
>>> [email protected]
>>> 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
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.