[sqlalchemy] Money composite column

2017-09-26 Thread Samer Atiani
Hello all, I'm trying to implement a solution whereby I store Money amounts in the database as both currency and amounts. The best I've come up with is in this gist: https://gist.github.com/satiani/b20d7e81e48a041d241d61e9aab61be2 It's important for me to be able to do comparisons and aggregate

Re: [sqlalchemy] Decimals generated as strings in query

2017-07-28 Thread Samer Atiani
m> wrote: > On Fri, Jul 28, 2017 at 1:46 PM, Samer Atiani <sati...@gmail.com> wrote: > > The way I'm handling this is by creating a TypeDecorator with the > following > > function: > > > > > > def bind_expression(self, value): > > "&q

Re: [sqlalchemy] Decimals generated as strings in query

2017-07-28 Thread Samer Atiani
The way I'm handling this is by creating a TypeDecorator with the following function: def bind_expression(self, value): """ The objective of this is to force MySQL to deal with bind parameters as decimals rather than as strings. MySQL for some insane reason

[sqlalchemy] Question about behavior of get_history for CompositeProperty

2017-02-07 Thread Samer Atiani
Hello All, Assume you have a CompositeProperty that depends on two properties, 'property_1' and 'property_2' and assume the constructor method for this property class does something like this: class ExampleCompositeProperty(object): def __init__(self, property_1, property_2): if property_1 is

Re: [sqlalchemy] Allow dynamic column names in CompositeProperty

2017-01-19 Thread Samer Atiani
Definitely simpler :) On Thu, Jan 19, 2017 at 16:23 mike bayer <mike...@zzzcomputing.com> wrote: On 01/19/2017 01:53 PM, Samer Atiani wrote: > I would like to allow some of the CompositeProperty columns I'm building > to get their names dynamically, in a manner that mirrors how

[sqlalchemy] Allow dynamic column names in CompositeProperty

2017-01-19 Thread Samer Atiani
I would like to allow some of the CompositeProperty columns I'm building to get their names dynamically, in a manner that mirrors how columns get their names in sqlalchemy's declarative mapper. The best way I found to implement this behavior is to do the following: class

[sqlalchemy] Dialect dependent REPLACEs

2013-09-17 Thread Samer Atiani
Hello, I'm trying to write a custom REPLACE expression that compiles differently on MySQL vs sqlite, namely it would look like REPLACE INTO in mysql and INSERT OR REPLACE in sqlite. I implemented it like so: class ReplaceInto(ValuesBase): def __init__(self, table, values=None):