My objective is to backup and restore a MYSQL table.
I am selecting all of the rows with (define sql-rows (query-rows...
I am dumping them to a file with (with-output-to-file "backup.dat" (lambda () (write sql-rows)...
This appears to work.
I am reading the data back with (define b-up (with-input-from-file "backup.dat" (lambda () (read)...
This fails with "read: bad syntax '#<' when it tries to read a SQL NULL, and I am puzzled as to how to get around this. On a simple test, read and write seem to handle the SQL-NULL if I don't go via a file port, but fail if I do. Probably something basic, as I am new to Racket, but I have not been able to find an answer in hunting through the documentation, so some help would be appreciated. Thanks.
Many of the Racket values that represent SQL scalar values are not readable (or at least do not survive write-read roundtripping). That includes the representation of NULL, dates and times, bit strings, geometric values, etc. But I believe all of them are serializable (see the racket/serialize library), so if you write the result of calling serialize on the rows and then call deserialize on the result of read, you should get back equivalent values.
Perfect! Much appreciated, that saved me a lot of head scratching.