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
b05f9c8a
Commit
b05f9c8a
authored
Sep 30, 2011
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
storage: extend syntax of database argument to specific socket of a MySQL DB
parent
8cb16d74
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
13 deletions
+12
-13
CHANGES
CHANGES
+2
-1
neo.conf
neo.conf
+3
-3
neo/storage/database/mysqldb.py
neo/storage/database/mysqldb.py
+7
-9
No files found.
CHANGES
View file @
b05f9c8a
...
...
@@ -4,7 +4,8 @@ Change History
0.9.2 (unreleased)
------------------
- storage: fix possible ConflictError when client is much faster than master
- storage: a specific socket can be given to MySQL backend
- storage: a ConflictError could happen when client is much faster than master
0.9.1 (2011-09-24)
------------------
...
...
neo.conf
View file @
b05f9c8a
...
...
@@ -31,8 +31,8 @@ partitions: 20
# Some parameters makes no sense to be defined in [DEFAULT] section.
# They are:
# bind: The ip:port the node will listen on.
# database: Storage nodes only.
The MySQL database credentials to use
#
(username:password@database).
# database: Storage nodes only.
#
Syntax for MySQL database is [user[:password]@]database[unix_socket]
# Those database must be created manualy.
# Admin node
...
...
neo/storage/database/mysqldb.py
View file @
b05f9c8a
...
...
@@ -22,6 +22,7 @@ from MySQLdb.constants.CR import SERVER_GONE_ERROR, SERVER_LOST
import
neo.lib
from
array
import
array
from
hashlib
import
md5
import
re
import
string
from
neo.storage.database
import
DatabaseManager
...
...
@@ -52,21 +53,16 @@ class MySQLDatabaseManager(DatabaseManager):
def
__init__
(
self
,
database
):
super
(
MySQLDatabaseManager
,
self
).
__init__
()
self
.
user
,
self
.
passwd
,
self
.
db
=
self
.
_parse
(
database
)
self
.
user
,
self
.
passwd
,
self
.
db
,
self
.
socket
=
self
.
_parse
(
database
)
self
.
conn
=
None
self
.
_config
=
{}
self
.
_connect
()
def
_parse
(
self
,
database
):
""" Get the database credentials (username, password, database) """
# expected pattern : [user[:password]@]database
username
=
None
password
=
None
if
'@'
in
database
:
(
username
,
database
)
=
database
.
split
(
'@'
)
if
':'
in
username
:
(
username
,
password
)
=
username
.
split
(
':'
)
return
(
username
,
password
,
database
)
# expected pattern : [user[:password]@]database[unix_socket]
return
re
.
match
(
'(?:([^:]+)(?::(.*))?@)?([^./]+)(.+)?$'
,
database
).
groups
()
def
close
(
self
):
self
.
conn
.
close
()
...
...
@@ -75,6 +71,8 @@ class MySQLDatabaseManager(DatabaseManager):
kwd
=
{
'db'
:
self
.
db
,
'user'
:
self
.
user
}
if
self
.
passwd
is
not
None
:
kwd
[
'passwd'
]
=
self
.
passwd
if
self
.
socket
:
kwd
[
'unix_socket'
]
=
self
.
socket
neo
.
lib
.
logging
.
info
(
'connecting to MySQL on the database %s with user %s'
,
self
.
db
,
self
.
user
)
...
...
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