https://github.com/dark-person/lazydb
Go SQLite collection for lazy people.
https://github.com/dark-person/lazydb
go sqlite
Last synced: 6 months ago
JSON representation
Go SQLite collection for lazy people.
- Host: GitHub
- URL: https://github.com/dark-person/lazydb
- Owner: dark-person
- License: mit
- Created: 2024-10-19T17:30:12.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-09-26T17:19:36.000Z (9 months ago)
- Last Synced: 2025-09-26T19:07:03.811Z (9 months ago)
- Topics: go, sqlite
- Language: Go
- Homepage:
- Size: 70.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# LazyDB
[](https://pkg.go.dev/github.com/dark-person/lazydb)

[](https://goreportcard.com/report/github.com/dark-person/lazydb)
Go SQLite collection for lazy people.
Include these feature:
- Create SQLite database file
- Migration with `fs.fs`
- Auto Backup when migration
- Manual backup by call function
Note: You must has `CGO` enabled to compile this project.
## Get Started
Run this command:
```bash
go get github.com/dark-person/lazydb
```
An example to use this package as:
```go
import (
"embed"
"fmt"
"github.com/dark-person/lazydb"
)
//go:embed all:schema
var schema embed.FS
func main() {
var err error
// Init db
db := lazydb.New(
lazydb.DbPath("path/data.db"), // Database path
lazydb.Migrate(schema, "schema"), // Migration schema location
lazydb.BackupDir("./backup"), // Set auto backup directory
lazydb.Version(2), // Specify Version
)
// Connect to db, which will create file if necessary
err = db.Connect()
if err != nil {
panic(err)
}
defer db.Close()
// Force Backup
err = db.BackupTo("somewhere/backup.db")
if err != nil {
panic(err)
}
// Migration performed
backup, err := db.Migrate()
if err != nil {
panic(err)
}
if backup != "" {
fmt.Println("Auto backup as migration performed: " + backup)
}
// Optional: Ensure connection is success
if !db.Connected() {
fmt.Println("Database is not connected")
}
// Usage here...
}
```