Re: Confusion over Python drivers - Mailing list pgsql-hackers

From Florian Weimer
Subject Re: Confusion over Python drivers
Date
Msg-id 87bpfz7cgp.fsf@mid.deneb.enyo.de
Whole thread Raw
In response to Re: Confusion over Python drivers  (Jeff Davis <pgsql@j-davis.com>)
Responses Re: Confusion over Python drivers  (Jeff Davis <pgsql@j-davis.com>)
List pgsql-hackers
* Jeff Davis:

> I have written up a set of guidelines for driver development based on
> what I learned working on ruby-pg:
>
> http://wiki.postgresql.org/wiki/Driver_development

Interesting, thanks.

I'm contemplating to create a new language binding for libpq (or, to
be more precise, turn an existing language binding into something that
can be published).  I've been agonizing a bit over how to create a
bridge between the host language type system and the PostgreSQL type
system.  If I understand you correctly, you suggest to leave
everything as strings.  This solution has the appeal of being
implemented easily.  It also sidesteps a lot of issues revolving
around different representation choices for numbers.

Do you really suggest to preserve the PQexecParams API verbatim, that
is, passing in three arrays containing type, value, and format?  That
seems to be a bit problematic.  I suspect the common case will be to
use unknown types, text format, and the default conversion from values
to strings.  Only for BYTEA values, something else is required, and
I'm wondering how to encode that (the host language doesn't offer a
distinction between text and binary strings).

Conversely, for result sets, I'm tempted to transparently decode
escaped BYTEA columns.

> Note that the ruby-pg driver doesn't 100% adhere to those standards
> (encoding is the primary problem, and that will be fixed).

Lack of Unicode support means that I can punt that to application
authors, I guess.

By the way, the downside of using strings everywhere is that your
binding API will most likely not work with SQLite (or any other
SQL-like database which lacks column type information).


pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: Order of operations in lazy_vacuum_rel
Next
From: Andres Freund
Date:
Subject: Re: Re: Faster CREATE DATABASE by delaying fsync (was 8.4.1 ubuntu karmic slow createdb)