Ideally this TIMESTAMP column would have a default declared at the server level:
CREATE TABLE mytable (
...
some_timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)
otherwise you're using python-side defaults, so you'd need to write a
post-table processing function:
from sqlalchemy import TIMESTAMP
def add_defaults(table):
for c in table.c:
if isinstance(c.type, TIMESTAMP):
c.default = <some default>
# ... or whatever you'd want here, c.server_default=FetchedValue(),
etc
On Sep 15, 2011, at 1:58 AM, Matt Bodman wrote:
> Hi,
>
> I am autoloading tables from an MSSQL db. A lot of the tables have
> the MSSQL TIMESTAMP column. So, when inserting to the table, I get an
> IntegrityError:
>
> sqlalchemy.exc.IntegrityError: (IntegrityError) ('23000', '[23000]
> [FreeTDS][SQL Server]Cannot insert an explicit value into a timestamp
> column. Use INSERT with a column list to exclude the timestamp column,
> or insert a DEFAULT into the timestamp column. (273) (SQLPrepare)'
>
> Is there a way around this without having to map every column
> explicitly?
>
> Thanks,
>
> Matt
>
> --
> 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.