From be09bb55ec97d941038b96dd811dc1f853a4c57c Mon Sep 17 00:00:00 2001 From: Richard Marko Date: Apr 27 2016 11:17:03 +0000 Subject: pass client_encoding utf8 to create_engine Resolves [:error] [pid 4455] UnicodeEncodeError: 'ascii' codec can't encode character u'\\xf6' in position 13: ordinal not in range(128) when getting user user = pagure.lib.search_user(SESSION, email=author.email) --- diff --git a/pagure/lib/__init__.py b/pagure/lib/__init__.py index c5ef2c6..e8d1891 100644 --- a/pagure/lib/__init__.py +++ b/pagure/lib/__init__.py @@ -84,7 +84,8 @@ def create_session(db_url, debug=False, pool_recycle=3600): ''' engine = sqlalchemy.create_engine( - db_url, echo=debug, pool_recycle=pool_recycle) + db_url, echo=debug, pool_recycle=pool_recycle, + client_encoding='utf8') scopedsession = scoped_session(sessionmaker(bind=engine)) model.BASE.metadata.bind = scopedsession return scopedsession diff --git a/pagure/lib/model.py b/pagure/lib/model.py index f4a0441..d905190 100644 --- a/pagure/lib/model.py +++ b/pagure/lib/model.py @@ -47,7 +47,7 @@ def create_tables(db_url, alembic_ini=None, acls=None, debug=False): :return a session that can be used to query the database. """ - engine = create_engine(db_url, echo=debug) + engine = create_engine(db_url, echo=debug, client_encoding='utf8') from pagure.ui.plugins import get_plugin_tables get_plugin_tables() BASE.metadata.create_all(engine)