I want to store matrices of the following form (but larger) in a database:
(define m '((0 1) (1 0)))
Currently I manage to store them by turning them into strings first via:
(~a (serialize m)); Or just drop the serialize, but I figured I might benefit from it later.
The problem is that I can only get a string out of the database. Obviously I could write a parser for this, but it feels a little odd having to write one for such a simple, and probably common, task.
The question I have is whether there is a common best practice for storing such things in a database, or whether I should write a parser? And if I should write a parser, I presume I should use either Parsack or Megaparsack?
Thanks,
Marc
Ah, except apparently `pg-array` only supports arrays with dimension 1. So... that won't help.
Using 6.0.1. I just painfully discovered that
(pg-array->list (list->pg-array (list)))
=> ERROR
pg-array->list: expected argument of type <pg-array of dimension 1>; given: (pg-array 0 '() '() '#())
The documentation for list->pg-array states that it produces an array of dimension 1. However, if you pass an empty list, you get back an array of dimension zero which you then can't transform back to a list [ except by going straight to the internal vector ].
My question is, "shouldn't these conversions be symmetric?" I understand an array with no elements is meaningless as an array, but Postgresql (ab)uses arrays as substitutes for lists and sets, so an empty array does have meaning.
--
You received this message because you are subscribed to a topic in the Google Groups "Racket Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/racket-users/xAbm8mlPX-w/unsubscribe.
To unsubscribe from this group and all its topics, send an email to racket-users+unsubscribe@googlegroups.com.
To unsubscribe from this group and all its topics, send an email to racket-users...@googlegroups.com.
--
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...@googlegroups.com.
To unsubscribe from this group and all its topics, send an email to racket-users+unsubscribe@googlegroups.com.
--
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+unsubscribe@googlegroups.com.
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.