Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefane Fermigier
neo
Commits
d5a0a0ea
Commit
d5a0a0ea
authored
Feb 14, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
d84bb116
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
2 deletions
+42
-2
go/neo/storage/sql/sql.go
go/neo/storage/sql/sql.go
+42
-2
No files found.
go/neo/storage/sql/sql.go
View file @
d5a0a0ea
...
...
@@ -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
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment