[erlang-questions] Re: Storing erlang terms in RDMBS

Koushik Narayanan koushik.list@REDACTED
Sun May 31 05:41:35 CEST 2009


Hi,

On Sat, May 30, 2009 at 04:51:38PM +0200, Robert Virding wrote:
> I suppose the real question is why you first convert something to a binary,
> then insert the printed representation of this in the data? Couldn't you in
> your case just insert the string "{a,b,1}", which is easy to parse when it
> has been extracted?
> 
> Otherwise you can parse it with:
> 
> {ok,Ts,_} = erl_scan:string(BinD),
> {ok,Bin} = erl_parse:term(Ts ++ [{dot,1}]),
> 
> If you add "." to the end of string when you generate it to put in the
> database then there is no need to append [{dot,1}]. And if you use ~w
> instead of ~p then you won't get the newlines and indentations in the
> generated string. This will make no difference to the parsing code above,
> but if it causes problems with the odbc query I don't know.
> 

Thanks a lot. I didn't know of the erl_scan and erl_parse modules, was searching
for the equivalent of a file:consult on strings to do this and never hit these
modules.

Koushik Narayanan 


More information about the erlang-questions mailing list