projects
/
zzz-pokedex.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Make plumbing respect the same env vars as the CLI. #180
[zzz-pokedex.git]
/
pokedex
/
db
/
__init__.py
diff --git
a/pokedex/db/__init__.py
b/pokedex/db/__init__.py
index
9e1b38c
..
e8976c4
100644
(file)
--- a/
pokedex/db/__init__.py
+++ b/
pokedex/db/__init__.py
@@
-1,3
+1,4
@@
+import os
import pkg_resources
from sqlalchemy import MetaData, Table, create_engine, orm
import pkg_resources
from sqlalchemy import MetaData, Table, create_engine, orm
@@
-13,7
+14,10
@@
def connect(uri=None, session_args={}, engine_args={}):
Calling this function also binds the metadata object to the created engine.
"""
Calling this function also binds the metadata object to the created engine.
"""
- # Default to a URI within the package, which was hopefully created at some point
+ # Fall back to the environment, then a URI within the package
+ if not uri:
+ uri = os.environ.get('POKEDEX_DB_ENGINE', None)
+
if not uri:
sqlite_path = pkg_resources.resource_filename('pokedex',
'data/pokedex.sqlite')
if not uri:
sqlite_path = pkg_resources.resource_filename('pokedex',
'data/pokedex.sqlite')