Hi there, I'm pretty new to Go and I'm looking for a database to use for a project I'm working on. I have a few requirements for it and I haven't been able to find anything that meets all of them yet.
- I would like to be able to interact with it with SQL or something SQL-like.
- I would like it to persist to disk in a plain-text file in some format that is easy for a human to make sense of (kind of like what Taskwarrior does).
- I would like it to be pure Go and not require any non-Go dependencies.
- Performance is NOT a requirement. It won't hold more than a few hundred objects and does not need to be particularly fast or resource-efficient.
Is there anything like this out there? Thanks!
评论:
gcapell:
magicjamesv:I worry that although you feel like you don't need it now, you'll be sorry later that you didn't go with some solid (but lightweight) DB. I'd suggest sqlite3 even though it seems like more than you need now.
mwholt:You might be right, but I'd really like something that writes to human-readable/editable files that users can easily make use of in other programs, pipe around in scripts, etc. if they want to.
magicjamesv:I thought I saw a Go package a while ago that basically does this for CSV files but I can't find the link right now... (am mobile)
magicjamesv:Also, thanks for Caddy! I've been using it for about a year now for all my personal projects and love it.
megromby:Something like that would be great. In the meantime, I wrote a small package for myself that basically does this with JSON, but if there is an existing package that writes to CSV and is more complete, I'd love to use that instead.
skidooer:It's probably https://github.com/gocarina/gocsv
Obviously this won't give you SQL functionality, but with only a few hundred objects you'd probably do just as well to do query/sort/filter/etc. with plain Go.
tormunds_beard:More like https://github.com/dinedal/textql
Allows you to easily execute SQL against structured text like CSV or TSV.
dark_magician2:In my experience postgres and go play pretty nicely together, it's what my project uses.
ecnahc515:Have you tried CockroachDB?
0xjnml:Very few things will natively do sql and a plaintext format on disk, largely because most things just implement sql care about performance and thus store things in a way that helps for doing relational queries and doing them fast, which a human readable plain text format is not good for.
Sqlite is C and not plain text but can easily give a csv file with a sql query.
You could look at textql which may let you build something closer to what you’re looking for. It’s written in Go so you can just reuse some of its packages.
Besides that I cannot think of anything that will do what you want without a good amount of effort or compromising.
Check https://godoc.org/go-hep.org/x/hep/csvutil/csvdriver
It's a CSV-backend wrapper for https://github.com/cznic/ql
