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

Robert Virding rvirding@REDACTED
Sat May 30 16:51:38 CEST 2009


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.

Robert


More information about the erlang-questions mailing list