On 12/11/2015 01:12 PM, mdob wrote:
> |
> 
> @event.listens_for(Table,'column_reflect')
> defreceive_column_reflect(inspector,table,column_info):
>     ifisinstance(column_info['type'],TIMESTAMP):
>         column_info['default']=FetchedValue()
> 

the reflection wants to assume the FetchedValue() is a reflected default
string, so just make it look like one:


column_info['default'] = "some_default"



> 

> 
>   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,inrun_callable
>   File"build/bdist.linux-x86_64/egg/sqlalchemy/engine/base.py",line
> 1477,inrun_callable
>   File"build/bdist.linux-x86_64/egg/sqlalchemy/engine/default.py",line
> 364,inreflecttable
>  
> File"build/bdist.linux-x86_64/egg/sqlalchemy/engine/reflection.py",line
> 568,inreflecttable
>  
> File"build/bdist.linux-x86_64/egg/sqlalchemy/engine/reflection.py",line
> 618,in_reflect_column
>   File"<string>",line 2,intext
>   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 stringorbuffer
> |
> 
> 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
>     
> <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 <mike.do...@gmail.com
>>     <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 sqlalchemy+...@googlegroups.com <javascript:>.
>>     To post to this group, send email to sqlal...@googlegroups.com
>>     <javascript:>.
>>     Visit this group at http://groups.google.com/group/sqlalchemy
>>     <http://groups.google.com/group/sqlalchemy>.
>>     For more options, visit https://groups.google.com/d/optout
>>     <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 sqlalchemy+unsubscr...@googlegroups.com
> <mailto:sqlalchemy+unsubscr...@googlegroups.com>.
> To post to this group, send email to sqlalchemy@googlegroups.com
> <mailto:sqlalchemy@googlegroups.com>.
> 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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to