Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
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
Carlos Ramos Carreño
neoppod
Commits
71564067
Commit
71564067
authored
Apr 10, 2024
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sqlite: accept -d URI, where query string can configure the DB connection
parent
a0280bec
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
8 deletions
+33
-8
neo.conf
neo.conf
+7
-2
neo/storage/database/sqlite.py
neo/storage/database/sqlite.py
+26
-6
No files found.
neo.conf
View file @
71564067
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
# for more information about the syntax.
# for more information about the syntax.
# ~ and ~user constructions are expanded for all paths, even for those that
# ~ and ~user constructions are expanded for all paths, even for those that
# may appear in 'database' option.
# may appear in 'database' option
(except SQLite URI)
.
# Common parameters.
# Common parameters.
[
DEFAULT
]
[
DEFAULT
]
...
@@ -58,7 +58,12 @@ partitions: 12
...
@@ -58,7 +58,12 @@ partitions: 12
# database: Storage nodes only. Syntax for:
# database: Storage nodes only. Syntax for:
# - MySQL: [user[:password]@]database[unix_socket]
# - MySQL: [user[:password]@]database[unix_socket]
# Database must be created manually.
# Database must be created manually.
# - SQLite: path
# - SQLite: path or URI
# URI extends the https://www.sqlite.org/c3ref/open.html syntax
# by accepting some PRAGMA settings via the query string
# (currently supported: cache_size, journal_mode, synchronous),
# but it can't be used yet to pass open options
# because Python 2.7's sqlite3.connect does not support URIs.
# engine: Optional parameter for MySQL.
# engine: Optional parameter for MySQL.
# Can be InnoDB (default) or RocksDB.
# Can be InnoDB (default) or RocksDB.
...
...
neo/storage/database/sqlite.py
View file @
71564067
...
@@ -20,8 +20,9 @@ import sqlite3
...
@@ -20,8 +20,9 @@ import sqlite3
from
hashlib
import
sha1
from
hashlib
import
sha1
import
string
import
string
import
traceback
import
traceback
from
urlparse
import
urlsplit
,
parse_qsl
from
.
import
LOG_QUERIES
from
.
import
LOG_QUERIES
,
DatabaseFailure
from
.manager
import
DatabaseManager
,
splitOIDField
from
.manager
import
DatabaseManager
,
splitOIDField
from
neo.lib
import
logging
,
util
from
neo.lib
import
logging
,
util
from
neo.lib.exception
import
NonReadableCell
,
UndoPackError
from
neo.lib.exception
import
NonReadableCell
,
UndoPackError
...
@@ -72,7 +73,22 @@ class SQLiteDatabaseManager(DatabaseManager):
...
@@ -72,7 +73,22 @@ class SQLiteDatabaseManager(DatabaseManager):
VERSION
=
4
VERSION
=
4
def
_parse
(
self
,
database
):
def
_parse
(
self
,
database
):
self
.
db
=
os
.
path
.
expanduser
(
database
)
pragmas
=
self
.
pragmas
=
{}
if
database
.
startswith
(
'file:'
):
database
=
urlsplit
(
database
)
for
k
,
v
in
parse_qsl
(
database
.
query
,
keep_blank_values
=
True
,
strict_parsing
=
True
):
if
k
in
pragmas
:
raise
DatabaseFailure
(
"duplicate pragma: "
+
k
)
if
k
not
in
(
'cache_size'
,
'journal_mode'
,
'synchronous'
):
raise
DatabaseFailure
(
"unsupported pragma: "
+
k
)
pragmas
[
k
]
=
v
self
.
db
=
database
.
path
else
:
self
.
db
=
os
.
path
.
expanduser
(
database
)
if
self
.
UNSAFE
:
pragmas
.
setdefault
(
'synchronous'
,
'OFF'
)
pragmas
.
setdefault
(
'journal_mode'
,
'MEMORY'
)
def
_close
(
self
):
def
_close
(
self
):
self
.
conn
.
close
()
self
.
conn
.
close
()
...
@@ -82,10 +98,14 @@ class SQLiteDatabaseManager(DatabaseManager):
...
@@ -82,10 +98,14 @@ class SQLiteDatabaseManager(DatabaseManager):
self
.
conn
=
sqlite3
.
connect
(
self
.
db
,
check_same_thread
=
False
)
self
.
conn
=
sqlite3
.
connect
(
self
.
db
,
check_same_thread
=
False
)
self
.
conn
.
text_factory
=
str
self
.
conn
.
text_factory
=
str
self
.
lockFile
(
self
.
db
)
self
.
lockFile
(
self
.
db
)
if
self
.
UNSAFE
:
try
:
q
=
self
.
query
for
pragma
in
map
(
"PRAGMA %s = %s"
.
__mod__
,
q
(
"PRAGMA synchronous = OFF"
).
fetchall
()
self
.
pragmas
.
iteritems
()):
q
(
"PRAGMA journal_mode = MEMORY"
).
fetchall
()
logging
.
info
(
pragma
)
self
.
query
(
pragma
).
fetchall
()
except
Exception
:
self
.
close
()
raise
self
.
_config
=
{}
self
.
_config
=
{}
def
_getDevPath
(
self
):
def
_getDevPath
(
self
):
...
...
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