[erlang-questions] Storing erlang terms in RDMBS

Anthony Shipman <>
Sat May 30 09:50:38 CEST 2009

On Fri, 29 May 2009 04:23:39 pm Koushik Narayanan wrote:
> Hi all,
> What is the right way to store erlang terms in a RDBMS accessed using
> the odbc application.
> Since the sql_param function takes a string as query argument, how do
> we write a binary and more importantly fetch it back ?
> One naive idea would be to base64 the binary, but that is ineffecient
> and surely there should be a better way.

"inefficient" will depend on whether you are looking to minimise time or 
space. I do
      term_to_binary -> zlib:deflate -> base64 encode
The deflate cancels out the space growth of base64. I doubt the execution time 
matters compared against the work done writing it to the db.

Anthony Shipman                    Mamas don't let your babies 
                   grow up to be outsourced.

More information about the erlang-questions mailing list