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: [mg106275] Re: Storing lists on SQL
  • From: "Hans Michel" <hmichel at cox.net>
  • Date: Thu, 7 Jan 2010 02:29:24 -0500 (EST)
  • References: <hi1qbt$eka$1@smc.vnet.net>

Try

In[1]:= ExportString["Hello World", "Base64"]
Out[1]= SGVsbG8gV29ybGQ=

You can also do expressions
ExportString[{1,"2",3}, "Base64"]
MQ0KMg0KMw==

ImportString[%,"Base64"]

{{1},{2},{3}}

Try

In[4]:= Compress[{1,"2",3}]
Out[4]= 1:eJxTTMoPSmNmYGAoZgESPpnFJZmMQEYwiDDKBEkAAGveBR0=
In[5]:= Uncompress[%]
Out[5]= {1,2,3}

Not certain if it may need further escaping when inserting into SQL database 
as a varchar.

Please not if you parametize your input variables before inserting, so you 
are passing parameters instead of raw data depending on the Database driver, 
you may not need to escape any characters as the parametization process may 
take care of those issue.

Hans

"Chris Degnen" <degnen at cwgsy.net> wrote in message 
news:hi1qbt$eka$1 at smc.vnet.net...
> 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.
>
> 



  • Prev by Date: Re: More /.{I->-1} craziness
  • Next by Date: Re: Re: Re: Re: algebraic numbers
  • Previous by thread: Storing lists on SQL
  • Next by thread: Re: Storing lists on SQL