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
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
5ce3ad70
Commit
5ce3ad70
authored
Jan 08, 2014
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
storage: add support for recent version of sqlite
parent
d4ed0828
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
2 deletions
+12
-2
neo/storage/database/sqlite.py
neo/storage/database/sqlite.py
+12
-2
No files found.
neo/storage/database/sqlite.py
View file @
5ce3ad70
...
...
@@ -25,6 +25,15 @@ from neo.lib import logging, util
from
neo.lib.exception
import
DatabaseFailure
from
neo.lib.protocol
import
CellStates
,
ZERO_OID
,
ZERO_TID
,
ZERO_HASH
def
unique_constraint_message
(
table
,
column
):
c
=
sqlite3
.
connect
(
":memory:"
)
c
.
execute
(
"CREATE TABLE %s (%s UNIQUE)"
%
(
table
,
column
))
try
:
c
.
executemany
(
"INSERT INTO %s VALUES(?)"
%
table
,
'xx'
)
except
sqlite3
.
IntegrityError
,
e
:
return
e
.
args
[
0
]
assert
False
def
splitOIDField
(
tid
,
oids
):
if
(
len
(
oids
)
%
8
)
!=
0
or
len
(
oids
)
==
0
:
raise
DatabaseFailure
(
'invalid oids length for tid %d: %d'
%
(
tid
,
...
...
@@ -360,13 +369,14 @@ class SQLiteDatabaseManager(DatabaseManager):
q
(
"DELETE FROM data WHERE id IN (%s)"
%
","
.
join
(
map
(
str
,
data_id_list
)))
def
_storeData
(
self
,
checksum
,
data
,
compression
):
def
_storeData
(
self
,
checksum
,
data
,
compression
,
_dup_hash
=
unique_constraint_message
(
"data"
,
"hash"
)):
H
=
buffer
(
checksum
)
try
:
return
self
.
query
(
"INSERT INTO data VALUES (NULL,?,?,?)"
,
(
H
,
compression
,
buffer
(
data
))).
lastrowid
except
sqlite3
.
IntegrityError
,
e
:
if
e
.
args
[
0
]
==
'column hash is not unique'
:
if
e
.
args
[
0
]
==
_dup_hash
:
(
r
,
c
,
d
),
=
self
.
query
(
"SELECT id, compression, value"
" FROM data WHERE hash=?"
,
(
H
,))
if
c
==
compression
and
str
(
d
)
==
data
:
...
...
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