Not sure why the documented approaches to server-side defaults aren't working
for you - I continue to recommend their use, or if there is some malfunction
I'd like to know of that as well so that it may be fixed. I use server-side
defaults on columns that are otherwise never touched by SQLA or the ORM without
issue as do hundreds of other users.
On Dec 21, 2010, at 11:48 AM, Tim Aerts wrote:
> I have found something that works. I'll share it here for future reference.
>
> To the MetaData I have added all the columns, etc that I needed to have in my
> actual DB (but not in my SA-mapping).
> I used that MetaData structure for the create_all() call. This takes care of
> the actual SQL schema creation as CREATE TABLE statements.
> I have removed all the columns, etc that I don't want SA to see or act upon
> from the MetaData structure.
> So what the SA mapper actually gets is less than what the RDBM got.
> This seems to work.
>
> Thank you anyway.
>
>
>
> Op 21/12/2010 16:09, Tim Aerts schreef:
>>
>> Yes, I do want to exclude it all together. But we are creating the database
>> from a createall() call. So if leave it out of the SA schema definition, it
>> will also disappear in the CREATE TABLE statements.
>>
>> Is there any way, whatsoever, to included them in the SA-generated CREATE
>> TABLE DDL without having them in the SA-generated INSERTs/UPDATEs?
>>
>>
>> Op 21/12/2010 15:59, Michael Bayer schreef:
>>> On Dec 21, 2010, at 8:36 AM, tim wrote:
>>>
>>>> Hi,
>>>>
>>>> I have some meta-data columns in my schema. How can I make sure they
>>>> are not part of the SELECT, INSERT and UPDATE statements SQLAlchemy is
>>>> doing in the background?
>>>>
>>>> I tried:
>>>>
>>>>
>>>> Column('lastUpdate', DateTime, DefaultClause('CURRENT_TIMESTAMP'),
>>>> nullable=False), # for Nebula's Syncer
>>>>
>>>>
>>>> along with
>>>>
>>>>
>>>> mapper(Location, locations, version_id_col=locations.c.STAMP,
>>>> exclude_properties=['lastUpdate'], properties = {
>>>> 'site': relation(Site, backref='locations'),
>>>> })
>>>>
>>>>
>>>> But the lastUpdate column still turns up in the SQL it is executing,
>>>> and what's worse, without using it's default value!
>>>>
>>>> Would anyone please help me out?
>>> If the column has an existing server-side default on it, you'd want to
>>> specify server_default=FetchedValue() :
>>> http://www.sqlalchemy.org/docs/core/schema.html#triggered-columns
>>>
>>> If you want to "exclude" the column from being used in your application in
>>> any way, simply don't place it in the Table definition. If you're using
>>> reflection, you could use the "include_columns" list on Table to specify
>>> which columns you want.
>>>
>>> "exclude_properties" in the ORM prevents those columns from being mapped,
>>> but doesn't prevent the core table level functionality from dealing with
>>> this column so that's why you need to ensure the Table metadata is correct.
>>>
>>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/sqlalchemy?hl=en.
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.