@event.listens_for(Table, 'column_reflect')
def receive_column_reflect(inspector, table, column_info):
if isinstance(column_info['type'], TIMESTAMP):
column_info['default'] = FetchedValue()
table = Table(table_name, metadata, autoload=True, autoload_with=engine,
include_columns=columns)
File "build/bdist.linux-x86_64/egg/sqlalchemy/sql/schema.py", line 416, in
__new__
File "build/bdist.linux-x86_64/egg/sqlalchemy/util/langhelpers.py", line
60, in __exit__
File "build/bdist.linux-x86_64/egg/sqlalchemy/sql/schema.py", line 411, in
__new__
File "build/bdist.linux-x86_64/egg/sqlalchemy/sql/schema.py", line 484, in
_init
File "build/bdist.linux-x86_64/egg/sqlalchemy/sql/schema.py", line 496, in
_autoload
File "build/bdist.linux-x86_64/egg/sqlalchemy/engine/base.py", line 1972,
in run_callable
File "build/bdist.linux-x86_64/egg/sqlalchemy/engine/base.py", line 1477,
in run_callable
File "build/bdist.linux-x86_64/egg/sqlalchemy/engine/default.py", line 364
, in reflecttable
File "build/bdist.linux-x86_64/egg/sqlalchemy/engine/reflection.py", line
568, in reflecttable
File "build/bdist.linux-x86_64/egg/sqlalchemy/engine/reflection.py", line
618, in _reflect_column
File "<string>", line 2, in text
File "build/bdist.linux-x86_64/egg/sqlalchemy/sql/elements.py", line 1425,
in _create_text
File "build/bdist.linux-x86_64/egg/sqlalchemy/sql/elements.py", line 1289,
in __init__
TypeError: expected string or buffer
Something's not right.
On Friday, November 14, 2014 at 3:48:59 PM UTC+1, Michael Bayer wrote:
>
> probably (maybe we should improve on our end, though). but when you’re
> autoloading, you can set this default up automatically using the
> column_reflect event:
>
>
> http://docs.sqlalchemy.org/en/rel_0_9/core/events.html?highlight=column_reflect#sqlalchemy.events.DDLEvents.column_reflect
>
> as you receive events here, look at the “type” to see if its TIMESTAMP,
> and if so, populate the column_info dictionary with column_info[‘default’]
> = FetchedValue().
>
>
> On Nov 14, 2014, at 7:04 AM, mdob <[email protected] <javascript:>>
> wrote:
>
> Hi,
>
> It's been some time since this topic was created. Has anything changed on
> that matter or manually setting column.server_default=FetchedValue() is
> still the best way to do it?
>
>
> Kind regards,
> Michał
>
> On Thursday, September 15, 2011 7:58:49 AM UTC+2, 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 unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected] <javascript:>.
> To post to this group, send email to [email protected]
> <javascript:>.
> Visit this group at http://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.
>
>
>
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.