Michael Bayer wrote:
Your suggest is fine, Michael,jose soares wrote: I tried this...but... class MyType(types.TypeDecorator): impl = types.Numeric def process_bind_param(self, value, dialect): return decimal.Decimal(str(value)) def process_result_value(self, value, dialect): return decimal.Decimal(str(value)) def copy(self): return MyType(self.impl.length) ..... test = Table('test', database.metadata, Column('id', Integer, nullable=False, primary_key=True), Column('data', Date, nullable=False), Column('importo', MyType(12,3)) ) .... insert into test(data,id,importo) values ('2009-01-01',2,32.331) select * from test id | data | importo -- + ------------------- + ------- 2 | 2009-01-01 00:00:00 | 32.331 $tg_admin shell In [36]: test Out[36]: Table('test',ThreadLocalMetaData(),Column('id',Integer(),primary_key=True,nullable=False),Column('data',Date(),nullable=False),Column('importo',MyType()),schema=None) In [37]: type(dict(test.select(test.c.id==2).execute().fetchone())['IMPORTO']) SELECT test.id, test.data, test.importo FROM test WHERE test.id = :test_id {'test_id': 2} Out[37]: <type 'float'> --------------------------------- What's wrong? j -- 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. |
- [sqlalchemy] TypeError: unsupported operand type(s) for +: '... jose soares
- Re: [sqlalchemy] TypeError: unsupported operand type(s)... Michael Bayer
- Re: [sqlalchemy] TypeError: unsupported operand typ... jose soares
- Re: [sqlalchemy] TypeError: unsupported operand... Michael Bayer
- Re: [sqlalchemy] TypeError: unsupported ope... jo
