Re: Converters for built-in types

"Antonio Valente" <[email protected]>
Newsgroups gmane.comp.python.db.pysqlite.user
Message-ID <[email protected]>
2006/9/25, Gerhard Häring <[email protected]>:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hello Antonio,
>
> Antonio Valente wrote:
> >
> > No, I need to have cursor's result wrapped in an object of mine and not
> > in python's strings when datatype is "char" or "varchar".
> > But if I install a converter function, it doesn't work for varchar since
> > I declare the column as "some_column varchar(20)": it looks for a
> > converter for "varchar(20)" type.
> > [...]
>
> There's currently no way to achieve this, apart from really just
> registering the "varchar(20)" type.


Mmm...not very good, I'm afraid...I don't use only varchar(20), and I cannot
register a converter for each size :-)

Alternatively, you could play tricks with the row_factory feature of
> pysqlite and convert unicode objects to objects of your own class, like
> this:



That's how I did before deciding to use adapters and converters...It seems
to me a very "dirty" solution, but maybe it's the "cleanest" one!

However, maybe it would be better to cut off the size spec from data type,
since I think nobody is interested in registering an adapter for something
like "varchar(20)"...I could post a patch to do that, if you want...

_______________________________________________
pysqlite mailing list
pysqlite-IAPFreCvJWPBWskQ1e/[email protected]
http://lists.initd.org/mailman/listinfo/pysqlite
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.