To work with strings for the database, do something like this:

(define (serialize-to-string v)
  (with-output-to-string
   (λ () (write (serialize v)))))
(define (deserialize-from-string str)
  (with-input-from-string str
   (λ () (deserialize (read)))))

On Tuesday, March 21, 2017 at 8:52:55 PM UTC-5, Marc Kaufmann wrote:
> Thanks, I will give that a try in the future, once I have time to look at PG 
> database (as I have some experience with Mysql, but none with PG). But that 
> would be exactly the kind of thing I was looking for.
> 
> 
> Cheers,
> 
> Marc
> 
> 
> 
> On Tue, Mar 21, 2017 at 8:47 PM, George Neuner <gneu...@comcast.net> wrote:
> 
>   
>     
>   
>   
> 
>     
> 
>     
> On 3/21/2017 8:36 PM, Marc Kaufmann
>       wrote:
> 
>     
>     
>       
> 
>         
> Thanks. But I have to turn it into a
>             string before storing it in the database; when I tried to
>             store a serialized list in it (in a VARCHAR field), it
>             complained that it expected a string. That's where all the
>             trouble came from. The trouble I had was parsing the string
>             back into the serialized form, which 'with-input-from-string
>             does (because, I presume, it treats the contents of the
>             string as the input, rather than the string itself). 
> 
>             
> 
>           
>         Of course, if there is a way to store
>           serialized data directly in the database, that would be great
>           - but -- except for arrays in a Postgre database -- that
>           doesn't seem to be the case.
> 
>       
>     
>     
> 
>     Serialize produce a list.  You might try storing it as JSON. 
>     Postgresql can parse and search JSON values.
> 
>     
> 
>     https://www.postgresql.org/docs/current/static/datatype-json.html
> 
>     https://www.postgresql.org/docs/current/static/functions-json.html
> 
>     
> 
>     
> 
>     George

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to