Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
configdb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
ai
configdb
Commits
ddd29d29
Commit
ddd29d29
authored
11 years ago
by
joe
Browse files
Options
Downloads
Patches
Plain Diff
Enabling etcd interface from the app; allowing input of db options
from the app config file.
parent
7df1c612
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
configdb/db/interface/sa_interface.py
+2
-2
2 additions, 2 deletions
configdb/db/interface/sa_interface.py
configdb/server/wsgiapp.py
+10
-2
10 additions, 2 deletions
configdb/server/wsgiapp.py
with
12 additions
and
4 deletions
configdb/db/interface/sa_interface.py
+
2
−
2
View file @
ddd29d29
...
@@ -44,7 +44,7 @@ class SqlAlchemyDbInterface(base.DbInterface):
...
@@ -44,7 +44,7 @@ class SqlAlchemyDbInterface(base.DbInterface):
AUDIT_SUPPORT
=
True
AUDIT_SUPPORT
=
True
def
__init__
(
self
,
uri
,
schema
,
schema_dir
=
None
):
def
__init__
(
self
,
uri
,
schema
,
schema_dir
=
None
,
opts
=
{}
):
self
.
Session
=
sessionmaker
(
autocommit
=
False
,
autoflush
=
False
)
self
.
Session
=
sessionmaker
(
autocommit
=
False
,
autoflush
=
False
)
Base
=
declarative_base
()
Base
=
declarative_base
()
...
@@ -53,7 +53,7 @@ class SqlAlchemyDbInterface(base.DbInterface):
...
@@ -53,7 +53,7 @@ class SqlAlchemyDbInterface(base.DbInterface):
self
.
_schema_dir
=
schema_dir
# unused, meant for caching
self
.
_schema_dir
=
schema_dir
# unused, meant for caching
self
.
_load_schema
()
self
.
_load_schema
()
self
.
engine
=
create_engine
(
uri
,
pool_recycle
=
1800
)
self
.
engine
=
create_engine
(
uri
,
pool_recycle
=
1800
,
**
opts
)
self
.
Session
.
configure
(
bind
=
self
.
engine
)
self
.
Session
.
configure
(
bind
=
self
.
engine
)
Base
.
metadata
.
create_all
(
self
.
engine
)
Base
.
metadata
.
create_all
(
self
.
engine
)
...
...
This diff is collapsed.
Click to expand it.
configdb/server/wsgiapp.py
+
10
−
2
View file @
ddd29d29
...
@@ -215,11 +215,12 @@ def make_app(config={}):
...
@@ -215,11 +215,12 @@ def make_app(config={}):
# Initialize the database interface.
# Initialize the database interface.
schema_obj
=
schema
.
Schema
(
app
.
config
[
'
SCHEMA_JSON
'
])
schema_obj
=
schema
.
Schema
(
app
.
config
[
'
SCHEMA_JSON
'
])
db_driver
=
app
.
config
.
get
(
'
DB_DRIVER
'
,
'
sqlalchemy
'
)
db_driver
=
app
.
config
.
get
(
'
DB_DRIVER
'
,
'
sqlalchemy
'
)
db_opts
=
app
.
config
.
get
(
'
DB_OPTIONS
'
,
{})
if
db_driver
==
'
sqlalchemy
'
:
if
db_driver
==
'
sqlalchemy
'
:
from
configdb.db.interface
import
sa_interface
from
configdb.db.interface
import
sa_interface
db
=
sa_interface
.
SqlAlchemyDbInterface
(
db
=
sa_interface
.
SqlAlchemyDbInterface
(
app
.
config
.
get
(
'
DB_URI
'
,
'
sqlite:///:memory:
'
),
app
.
config
.
get
(
'
DB_URI
'
,
'
sqlite:///:memory:
'
),
schema_obj
)
schema_obj
,
opts
=
db_opts
)
elif
db_driver
==
'
leveldb
'
:
elif
db_driver
==
'
leveldb
'
:
from
configdb.db.interface
import
leveldb_interface
from
configdb.db.interface
import
leveldb_interface
db
=
leveldb_interface
.
LevelDbInterface
(
db
=
leveldb_interface
.
LevelDbInterface
(
...
@@ -230,8 +231,15 @@ def make_app(config={}):
...
@@ -230,8 +231,15 @@ def make_app(config={}):
if
not
'
ZK_HOSTS
'
in
app
.
config
:
if
not
'
ZK_HOSTS
'
in
app
.
config
:
raise
Exception
(
'
you need to define ZK_HOSTS list to use zookeeper as db backend
'
)
raise
Exception
(
'
you need to define ZK_HOSTS list to use zookeeper as db backend
'
)
db
=
zookeeper_interface
.
ZookeeperInterface
(
app
.
config
[
'
ZK_HOSTS
'
],
schema_obj
,
app
.
config
[
'
DB_URI
'
])
db
=
zookeeper_interface
.
ZookeeperInterface
(
app
.
config
[
'
ZK_HOSTS
'
],
schema_obj
,
app
.
config
[
'
DB_URI
'
])
elif
db_driver
==
'
etcd
'
:
from
configdb.db.interface
import
etcd_interface
if
not
'
ETCD_URL
'
in
app
.
config
:
raise
Exception
(
'
You need to define an ETCD_URL to use the etcd backend
'
)
db
=
etcd_interface
.
EtcdInterface
(
app
.
config
[
'
ETCD_URL
'
],
schema_obj
,
**
db_opts
)
else
:
else
:
raise
Exception
(
'
DB_DRIVER not
one of
"
sqlalchemy
"
or
"
leveldb
"'
)
raise
Exception
(
'
DB_DRIVER not
supported: %s
'
%
db_driver
)
app
.
api
=
db_api
.
AdmDbApi
(
schema_obj
,
db
)
app
.
api
=
db_api
.
AdmDbApi
(
schema_obj
,
db
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment