X-Git-Url: http://git.veekun.com/zzz-pokedex.git/blobdiff_plain/a1cdf50e2d333aee2267af6987dc1cf468fbc160..55758f863e5137fd44e4b43f3c2a63005177f08c:/pokedex/db/__init__.py diff --git a/pokedex/db/__init__.py b/pokedex/db/__init__.py index 140994b..464629d 100644 --- a/pokedex/db/__init__.py +++ b/pokedex/db/__init__.py @@ -1,12 +1,14 @@ # encoding: utf-8 import re -from sqlalchemy import MetaData, Table, engine_from_config, orm +from sqlalchemy import engine_from_config, orm from ..defaults import get_default_db_uri -from .tables import metadata +from .tables import Language, metadata from .multilang import MultilangSession, MultilangScopedSession +ENGLISH_ID = 9 + def connect(uri=None, session_args={}, engine_args={}, engine_prefix=''): """Connects to the requested URI. Returns a session object. @@ -44,7 +46,8 @@ def connect(uri=None, session_args={}, engine_args={}, engine_prefix=''): all_session_args = dict(autoflush=True, autocommit=False, bind=engine) all_session_args.update(session_args) - sm = orm.sessionmaker(class_=MultilangSession, **all_session_args) + sm = orm.sessionmaker(class_=MultilangSession, + default_language_id=ENGLISH_ID, **all_session_args) session = MultilangScopedSession(sm) return session