dolthub / go-mysql-server

A MySQL-compatible relational database with a storage agnostic query engine. Implemented in pure Go.
Apache License 2.0
2.31k stars 197 forks source link

Feature request: persistent database store #2428

Open jonahzheng opened 4 months ago

jonahzheng commented 4 months ago

go-mysql-server, how to save data to hard disk?

zachmu commented 4 months ago

Hi @jonahzheng,

There is no persistent database implementation built into the package. The provided memory implementation only persists in memory for a single process's lifetime. You would need to implement a persistent version to get this functionality.

We would take this contribution as a patch if you wanted to write it. A first attempt would probably extend the memory.Database and serialize table schemas as CREATE TABLE statements, and table data as CSV or JSON. Happy to provide additional pointers if you or someone else want to attempt this.

Alternately, you could build on top of Dolt, which is MySQL compatible and uses go-mysql-server as its query layer. Then you get persistence for free.

https://github.com/dolthub/dolt

Depending on what you're trying to do, the driver package might be a more convenient way to build on top of Dolt:

https://github.com/dolthub/driver