[Prophesy] Binary data and Postgres/SQL

Daniel Phillips phillips at bonn-fries.net
Fri May 31 11:50:39 EST 2002


Today I'm thinking a little about how best to interface the scm to the 
database, particularly how to get the binary transforms[1] in and out.  It 
seems to me the sql COPY command does what we need:

  http://postgresql.org/users-lounge/docs/7.2/postgres/sql-copy.html

I don't like the idea at all of forming such data into ascii strings, as part 
of an INSERT command.  So the proposed strategy is the place the data in a 
temporary file and issue a COPY command.  A ramfs mount will do nicely for 
this.

We can use this technique to extend Python's database interface to handle 
inserts in a way similar to retrieves, if we want, and for databases that 
can't handle such a thing, the interface can fall back to forming the ascii 
INSERT string, as you must do now anyway.  Of course, improving the Python 
interface isn't our immediate concern, it's just nice to know that we can.

In my opinion, the INSERT command should only ever be used for data that is 
ascii by nature, such as parameters read from a config file or input by a 
user.

[1] See yesterday.

-- 
Daniel



More information about the Prophesy mailing list