Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Storing lists on SQL

  • To: mathgroup at smc.vnet.net
  • Subject: [mg106301] Re: Storing lists on SQL
  • From: Albert Retey <awnl at gmx-topmail.de>
  • Date: Thu, 7 Jan 2010 02:34:46 -0500 (EST)
  • References: <hi1qbt$eka$1@smc.vnet.net>

Hi,

> Hi. I'm trying to store lists on an SQL database.  The lists can
> contain strings, rules, lists and integers etc. I plan to store them
> in a variable character field as a single string, but the first
> problem is the quotes on the inner strings have to be elided, e.g./"
> 
> At the moment I'm trying a recursive routine with ToCharacterCode[] to
> encode the inner strings first.  I'll have to do something else for
> the rules.
> 
> I'm also going to try serializing the lists with Export[] and then
> storing them encoded.  (That might be easiest.)
> 
> If anyone has suggestions on how I might store these lists please let
> me know.

If you use a recent version (6 or 7) I think the simplest approach to
achieve exactly what you want is to use Compress to create a string that
should be o.k. as a variable character field with most SQL databases
(from the docs: "The string generated by Compress contains only
printable ASCII characters."). Of course you will need to Uncompress
after reading from the database. Struggling with character codes is
probably only necessary if you want to store the data as binary (e.g.
BLOB) and/or if you need to read/write with another system/language.

On the other hand, if your lists basically contain strings and integers
only, why not store them as such in the database? Rules and sublists can
probably be resolved by introducing extra tables in the database
(learning the details about normalizing relational databases might be
overkill, but the basics are not so complicated).

If that is not an option, probably because the data is too irregular,
you could also use SQLExpr (assuming you use DatabaseLink`), which I
think is exactly for the purpose you are after and basically does the
same thing as Compress/Uncompress, I believe...

hth,

albert


  • Prev by Date: Re: Re: Re: Re: algebraic numbers
  • Next by Date: Re: Re: algebraic numbers
  • Previous by thread: Re: Storing lists on SQL
  • Next by thread: Re: Storing lists on SQL