session.
"""
+ # WARNING: This logic duplicates that in db.connect(), because there's no
+ # other reliable way to tell where the engine actually came from. Keep it
+ # up to date!
engine_uri = options.engine_uri
got_from = None
if engine_uri:
PokedexLookup object.
"""
+ # WARNING: This logic duplicates that in PokedexLookup, because there's no
+ # other reliable way to tell where the engine actually came from. Keep it
+ # up to date!
if recreate and not session:
raise ValueError("get_lookup() needs an explicit session to regen the index")
+import os
import pkg_resources
from sqlalchemy import MetaData, Table, create_engine, orm
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')
# Defaults
if not directory:
+ directory = os.environ.get('POKEDEX_INDEX_DIR', None)
+
+ if not directory:
directory = pkg_resources.resource_filename('pokedex',
'data/whoosh-index')
self.directory = directory