forked from MTSR/mapserver
sqlite3
This commit is contained in:
parent
8740ad76f4
commit
34bf2c5df9
@ -9,7 +9,7 @@ type Block struct {
|
||||
type DBAccessor interface {
|
||||
IsMigrated() (bool, error)
|
||||
Migrate() error
|
||||
FindLatestBlocks(mintime int64, limit int) []Block, error
|
||||
FindBlocks(posx int, posz int, posystart int, posyend int) []Block, error
|
||||
CountBlocks(x1, x2, y1, y2, z1, z2 int) int, error
|
||||
FindLatestBlocks(mintime int64, limit int) ([]Block, error)
|
||||
FindBlocks(posx int, posz int, posystart int, posyend int) ([]Block, error)
|
||||
CountBlocks(x1, x2, y1, y2, z1, z2 int) (int, error)
|
||||
}
|
||||
|
20
db/sqlite.go
20
db/sqlite.go
@ -1,6 +1,12 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
)
|
||||
|
||||
type Sqlite3Accessor struct {
|
||||
db *sql.DB
|
||||
}
|
||||
|
||||
func (db *Sqlite3Accessor) IsMigrated() (bool, error) {
|
||||
@ -12,17 +18,23 @@ func (db *Sqlite3Accessor) Migrate() error {
|
||||
}
|
||||
|
||||
func (db *Sqlite3Accessor) FindLatestBlocks(mintime int64, limit int) ([]Block, error) {
|
||||
return make([]Block, 0)
|
||||
return make([]Block, 0), nil
|
||||
}
|
||||
|
||||
func (db *Sqlite3Accessor) FindBlocks(posx int, posz int, posystart int, posyend int) ([]Block, error) {
|
||||
return make([]Block, 0)
|
||||
return make([]Block, 0), nil
|
||||
}
|
||||
|
||||
func (db *Sqlite3Accessor) CountBlocks(x1, x2, y1, y2, z1, z2 int) (int, error) {
|
||||
return 0
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
func NewSqliteAccessor(filename string) (*Sqlite3Accessor, error) {
|
||||
return nil, nil
|
||||
db, err := sql.Open("sqlite3", filename + "?mode=ro")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
sq := &Sqlite3Accessor{db: db}
|
||||
return sq, nil
|
||||
}
|
||||
|
5
go.mod
5
go.mod
@ -1,3 +1,6 @@
|
||||
module mapserver
|
||||
|
||||
require github.com/sirupsen/logrus v1.3.0
|
||||
require (
|
||||
github.com/mattn/go-sqlite3 v1.10.0
|
||||
github.com/sirupsen/logrus v1.3.0
|
||||
)
|
||||
|
2
go.sum
2
go.sum
@ -1,6 +1,8 @@
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/mattn/go-sqlite3 v1.10.0 h1:jbhqpg7tQe4SupckyijYiy0mJJ/pRyHvXf7JdWK860o=
|
||||
github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/sirupsen/logrus v1.3.0 h1:hI/7Q+DtNZ2kINb6qt/lS+IyXnHQe9e90POfeewL/ME=
|
||||
|
Loading…
Reference in New Issue
Block a user