Commit d5a0a0ea authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent d84bb116
......@@ -20,21 +20,61 @@
// Package sql provides NEO storage backend that uses SQL database for persistence.
package sql
// TODO also support mysql
import (
"context"
"net/url"
//"lab.nexedi.com/kirr/go123/mem"
"lab.nexedi.com/kirr/go123/mem"
"lab.nexedi.com/kirr/neo/go/neo/storage"
//"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/neo/go/zodb"
"database/sql"
_ "github.com/mattn/go-sqlite3"
_ "github.com/go-sql-driver/mysql"
)
type SQLBackend struct {
db *sql.DB
}
var _ storage.Backend = (*SQLBackend)(nil)
func (b *SQLBackend) LastTid(ctx context.Context) (zodb.Tid, error) {
panic("TODO")
}
func (b *SQLBackend) LastOid(ctx context.Context) (zodb.Oid, error) {
panic("TODO")
}
func (b *SQLBackend) Load(ctx context.Context, xid zodb.Xid) (*mem.Buf, zodb.Tid, zodb.Tid, error) {
panic("TODO")
}
// ---- open by URL ----
func openURL(ctx context.Context, u *url.URL) (storage.Backend, error) {
// TODO handle query
// XXX u.Path is not always raw path - recheck and fix
path := u.Host + u.Path
db, err := sql.Open("sqlite3", path) // XXX +context
if err != nil {
return nil, err
}
// check we can actually access db
err = db.PingContext(ctx)
if err != nil {
// XXX db.Close()
return nil, err // XXX err ctx
}
return nil, nil
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment