From cd0b04e7611b2a1fbb25bb874ea73fe61eeb8b23 Mon Sep 17 00:00:00 2001 From: Ryan Lerch Date: Apr 28 2016 13:11:31 +0000 Subject: not use client_encoding if using sqlite --- diff --git a/pagure/lib/__init__.py b/pagure/lib/__init__.py index e8d1891..12608b2 100644 --- a/pagure/lib/__init__.py +++ b/pagure/lib/__init__.py @@ -83,9 +83,13 @@ def create_session(db_url, debug=False, pool_recycle=3600): :return a Session that can be used to query the database. ''' - engine = sqlalchemy.create_engine( - db_url, echo=debug, pool_recycle=pool_recycle, - client_encoding='utf8') + if db_url.partition(":")[0] == "sqlite": + engine = sqlalchemy.create_engine( + db_url, echo=debug, pool_recycle=pool_recycle) + else: + engine = sqlalchemy.create_engine( + 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 d905190..62287ca 100644 --- a/pagure/lib/model.py +++ b/pagure/lib/model.py @@ -47,7 +47,11 @@ 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, client_encoding='utf8') + if db_url.partition(":")[0] == "sqlite": + engine = create_engine(db_url, echo=debug) + else: + 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)