On Wed, Apr 18, 2012 at 10:57 AM, Michael Bayer <[email protected]>wrote:

>
> On Apr 18, 2012, at 10:47 AM, Will wrote:
>
>
> Yes, I knew about the adapters.  A coworker of mine came up with this:
>
>    ...
>
> s = Session()
> c = s.connection()
>
> cast_time = lambda value, cur: Time.parse(value)
> TIME = c.dialect.dbapi.extensions.new_type((1083,), "TIME", cast_time)
>
>   c.dialect.dbapi.extensions.register_type(TIME)
>
> I should have mentioned that in the first place.  I was wondering, what's
> the recommended way to modify the dialect settings globally, so they are
> used whenever a new engine/connection is created?
>
>
> Since you're doing things that are psycopg2 specific, you could just
> import psycopg2:
>
> from psycopg2 import extensions
> extensions.register_type(...)
>
> if you wanted to keep it local to an engine, you could do a "connect"
> event to add connection scope:
>
> from psycopg2 import extensions
>
> @event.listens_for(myengine, "connect")
> def setup_time_type(dbapi_conn, conn_rec):
>     extensions.register_type(TIME, dbapi_conn)
>

Awesome, I'll try that out.  Thanks for the input, and as always thanks for
the quick reply.

-- 
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.

Reply via email to