X-Git-Url: http://git.veekun.com/zzz-pokedex.git/blobdiff_plain/80d10860ac295ff3fb988b428742863ceb7f44cf..47218a7fb65bb2ad2e1c0808d4a2c56046f3740b:/pokedex/db/__init__.py?ds=sidebyside diff --git a/pokedex/db/__init__.py b/pokedex/db/__init__.py index 9e1b38c..e8976c4 100644 --- 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 @@ -13,7 +14,10 @@ def connect(uri=None, session_args={}, engine_args={}): 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')