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
d63e45d3
Commit
d63e45d3
authored
Jun 19, 2014
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
storage: lazy import of backends
parent
ca0afaa3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
15 deletions
+12
-15
neo/storage/database/__init__.py
neo/storage/database/__init__.py
+12
-15
No files found.
neo/storage/database/__init__.py
View file @
d63e45d3
...
@@ -18,22 +18,19 @@ LOG_QUERIES = False
...
@@ -18,22 +18,19 @@ LOG_QUERIES = False
from
neo.lib.exception
import
DatabaseFailure
from
neo.lib.exception
import
DatabaseFailure
from
.manager
import
DatabaseManager
from
.manager
import
DatabaseManager
from
.sqlite
import
SQLiteDatabaseManager
DATABASE_MANAGER_DICT
=
{
'SQLite'
:
SQLiteDatabaseManager
}
DATABASE_MANAGER_DICT
=
{
'MySQL'
:
'mysqldb.MySQLDatabaseManager'
,
'SQLite'
:
'sqlite.SQLiteDatabaseManager'
,
}
try
:
def
getAdapterKlass
(
name
):
from
.mysqldb
import
MySQLDatabaseManager
try
:
except
ImportError
:
module
,
name
=
DATABASE_MANAGER_DICT
[
name
or
'MySQL'
].
split
(
'.'
)
pass
except
KeyError
:
else
:
DATABASE_MANAGER_DICT
[
'MySQL'
]
=
MySQLDatabaseManager
def
buildDatabaseManager
(
name
,
args
=
(),
kw
=
{}):
if
name
is
None
:
name
=
DATABASE_MANAGER_DICT
.
keys
()[
0
]
adapter_klass
=
DATABASE_MANAGER_DICT
.
get
(
name
,
None
)
if
adapter_klass
is
None
:
raise
DatabaseFailure
(
'Cannot find a database adapter <%s>'
%
name
)
raise
DatabaseFailure
(
'Cannot find a database adapter <%s>'
%
name
)
return
adapter_klass
(
*
args
,
**
kw
)
module
=
getattr
(
__import__
(
__name__
,
fromlist
=
[
module
],
level
=
1
),
module
)
return
getattr
(
module
,
name
)
def
buildDatabaseManager
(
name
,
args
=
(),
kw
=
{}):
return
getAdapterKlass
(
name
)(
*
args
,
**
kw
)
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