* sabato 20 gennaio 2007, alle 02:57, exhuma.twn wrote :
> > > Sorry,
> > > but I don't understand how create, insert or select data with the array
> > > field in postgres.

I use a composite type in PostgreSQL 

fatture=# \d datirim
Composite type "public.datirim"
Column |          Type
--------+------------------------
rim    | smallint
hat    | time without time zone
hin    | time without time zone
hfn    | time without time zone
turno  | character(1)

in sqlalchemy:


import sqlalchemy as sqa
import re

class _RimType(sqa.types.TypeEngine):
        def __init__(self):
                pass
        def get_col_spec(self):
                pass
        def convert_bind_param(self, value, engine):
                return '('+",".join(value)+')'
        def convert_result_value(self, value, engine):
                arr = re.sub('[()]','',value).split(',')
                return 'Nome %s HAT "%s" HIN "%s" HFN "%s"' % \
                        (arr[0],arr[1],arr[2],arr[3])

.....

_elem_tbl=sqa.Table('elem', _mdata,
        sqa.Column('id', sqa.Integer, primary_key=True),
        sqa.Column('rim1', _RimType),
        sqa.Column('rim2', _RimType),
        sqa.Column('tempo', sqa.Time)
)

you can use a similar class for arrays

bye ...

PS sorry for my english ;-)))

-- 
#include <stdio.h>
int main(void){char c[]={10,65,110,116,111,110,105,111,32,98,97,114,98,111,110,
101,32,60,104,105,110,100,101,109,105,116,64,116,105,115,99,97,108,105,110,101,
116,46,105,116,62,10,10,0};printf("%s",c);return 0;}

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