Datetimes and SQLite.jl encoding

Hey all, hopefully this is the right place to post this question since I have no idea if its a lack of my own knowledge, or SQLite.jl, SQLite, or encodings in general.

I did some work a while ago in Julia, and used the SQLite.jl package to save my results, one of the columns storing a DateTime object.

I’m now trying to use this SQLite database with Python, but I can’t seem to decode the datetime part.

This is what python sees:


which to me is vaguely intelligible as some sort of byte representation of the julia datetime type.

My first instinct is that its perhaps corrupted. But every single row follows a similar format, and furthermore, it looks like Julia reads it just fine

julia> SQLite.query(ssdb, "select datetime from streetsegmentinfraction limit 5")
5×1 DataFrame
│ Row │ datetime            │
│ 1   │ 2016-01-01T00:00:00 │
│ 2   │ 2016-01-01T00:01:00 │
│ 3   │ 2016-01-01T00:02:00 │
│ 4   │ 2016-01-01T00:02:00 │
│ 5   │ 2016-01-01T00:02:00 │

I googled around for what kind of encoding this might be, but didn’t find anything that looked helpful, which may be due to me not knowing what to look for.

If it’s any help, I’m on Julia 1.0, running on a linux machine.

I’d appreciate any leads on this. Cheers!

DateTimes in SQLite.jl use julia’s builtin serialize format; for compat with other sqlite clients, you’d probably be best off to call string on the values first.

Thanks, I think that’s the easiest way forward for me. For completeness, are there any alternative ways to go about reading the serealized format in other programs?

Not really. I should probably special-case Date/DateTimes in SQLite.jl to store them as text anyway since they’re common and the interop w/ other languages is more important. The use of Julia’s serialize should really only be used for custom Julia types that would be more obviously tied to using Julia itself to query.

1 Like

I opened an issue so I don’t forget: