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
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
neoppod
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
Hide 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
...
@@ -4,7 +4,8 @@ Change History
0.9.2 (unreleased)
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)
0.9.1 (2011-09-24)
------------------
------------------
...
...
neo.conf
View file @
b05f9c8a
...
@@ -31,9 +31,9 @@ partitions: 20
...
@@ -31,9 +31,9 @@ partitions: 20
# Some parameters makes no sense to be defined in [DEFAULT] section.
# Some parameters makes no sense to be defined in [DEFAULT] section.
# They are:
# They are:
# bind: The ip:port the node will listen on.
# bind: The ip:port the node will listen on.
# database: Storage nodes only.
The MySQL database credentials to use
# database: Storage nodes only.
#
(username:password@database).
#
Syntax for MySQL database is [user[:password]@]database[unix_socket]
#
Those database must be created manualy.
# Those database must be created manualy.
# Admin node
# Admin node
[
admin
]
[
admin
]
...
...
neo/storage/database/mysqldb.py
View file @
b05f9c8a
...
@@ -22,6 +22,7 @@ from MySQLdb.constants.CR import SERVER_GONE_ERROR, SERVER_LOST
...
@@ -22,6 +22,7 @@ from MySQLdb.constants.CR import SERVER_GONE_ERROR, SERVER_LOST
import
neo.lib
import
neo.lib
from
array
import
array
from
array
import
array
from
hashlib
import
md5
from
hashlib
import
md5
import
re
import
string
import
string
from
neo.storage.database
import
DatabaseManager
from
neo.storage.database
import
DatabaseManager
...
@@ -52,21 +53,16 @@ class MySQLDatabaseManager(DatabaseManager):
...
@@ -52,21 +53,16 @@ class MySQLDatabaseManager(DatabaseManager):
def
__init__
(
self
,
database
):
def
__init__
(
self
,
database
):
super
(
MySQLDatabaseManager
,
self
).
__init__
()
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
.
conn
=
None
self
.
_config
=
{}
self
.
_config
=
{}
self
.
_connect
()
self
.
_connect
()
def
_parse
(
self
,
database
):
def
_parse
(
self
,
database
):
""" Get the database credentials (username, password, database) """
""" Get the database credentials (username, password, database) """
# expected pattern : [user[:password]@]database
# expected pattern : [user[:password]@]database[unix_socket]
username
=
None
return
re
.
match
(
'(?:([^:]+)(?::(.*))?@)?([^./]+)(.+)?$'
,
password
=
None
database
).
groups
()
if
'@'
in
database
:
(
username
,
database
)
=
database
.
split
(
'@'
)
if
':'
in
username
:
(
username
,
password
)
=
username
.
split
(
':'
)
return
(
username
,
password
,
database
)
def
close
(
self
):
def
close
(
self
):
self
.
conn
.
close
()
self
.
conn
.
close
()
...
@@ -75,6 +71,8 @@ class MySQLDatabaseManager(DatabaseManager):
...
@@ -75,6 +71,8 @@ class MySQLDatabaseManager(DatabaseManager):
kwd
=
{
'db'
:
self
.
db
,
'user'
:
self
.
user
}
kwd
=
{
'db'
:
self
.
db
,
'user'
:
self
.
user
}
if
self
.
passwd
is
not
None
:
if
self
.
passwd
is
not
None
:
kwd
[
'passwd'
]
=
self
.
passwd
kwd
[
'passwd'
]
=
self
.
passwd
if
self
.
socket
:
kwd
[
'unix_socket'
]
=
self
.
socket
neo
.
lib
.
logging
.
info
(
neo
.
lib
.
logging
.
info
(
'connecting to MySQL on the database %s with user %s'
,
'connecting to MySQL on the database %s with user %s'
,
self
.
db
,
self
.
user
)
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