On Jul 9, 2013, at 7:49 AM, Felix Schwarz <[email protected]> wrote:

> 
> I'm trying to get rid of SQLAlchemy's warning regarding problematic storage of
> numeric/decimal objects in sqlite.
> 
> My idea was to build a custom type which is backed by a string on sqlite but
> uses the native DB types when available.


I'd advise storing the value as a whole integer with a fixed radix.  that way 
you can still do math with it on the DB side.



> 
> Well, the basics (dialect-specific conversion) seem to be easy enough but I'm
> not sure how I can create the right colspec when initializing the new db (for
> example using 'alembic upgrade --sql')


> sqlalchemy.types.UserDefinedType has a method "get_col_spec()" but that method
> has no information about the dialect or dbapi.

you should be using TypeDecorator here, on top of NUMERIC and if SQLite is in 
use on top of INTEGER - use the load_dialect_impl() method illustrated at 
http://docs.sqlalchemy.org/en/rel_0_8/core/types.html#backend-agnostic-guid-type
 to do this.

-- 
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/groups/opt_out.


Reply via email to