Skip to content

Commit

Permalink
Added the engine_options option to SQLAlchemyJobStore
Browse files Browse the repository at this point in the history
Fixes #228.
  • Loading branch information
agronholm committed Nov 6, 2017
1 parent 64482a7 commit 51f76ae
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
17 changes: 10 additions & 7 deletions apscheduler/jobstores/sqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,31 @@ class SQLAlchemyJobStore(BaseJobStore):
Plugin alias: ``sqlalchemy``
:param str url: connection string (see `SQLAlchemy documentation
<http://docs.sqlalchemy.org/en/latest/core/engines.html?highlight=create_engine#database-urls>`_
on this)
:param engine: an SQLAlchemy Engine to use instead of creating a new one based on ``url``
:param str url: connection string (see
:ref:`SQLAlchemy documentation <sqlalchemy:database_urls>` on this)
:param engine: an SQLAlchemy :class:`~sqlalchemy.engine.Engine` to use instead of creating a
new one based on ``url``
:param str tablename: name of the table to store jobs in
:param metadata: a :class:`~sqlalchemy.MetaData` instance to use instead of creating a new one
:param metadata: a :class:`~sqlalchemy.schema.MetaData` instance to use instead of creating a
new one
:param int pickle_protocol: pickle protocol level to use (for serialization), defaults to the
highest available
:param str tableschema: name of the (existing) schema in the target database where the table
should be
:param dict engine_options: keyword arguments to :func:`~sqlalchemy.create_engine`
(ignored if ``engine`` is given)
"""

def __init__(self, url=None, engine=None, tablename='apscheduler_jobs', metadata=None,
pickle_protocol=pickle.HIGHEST_PROTOCOL, tableschema=None):
pickle_protocol=pickle.HIGHEST_PROTOCOL, tableschema=None, engine_options=None):
super(SQLAlchemyJobStore, self).__init__()
self.pickle_protocol = pickle_protocol
metadata = maybe_ref(metadata) or MetaData()

if engine:
self.engine = maybe_ref(engine)
elif url:
self.engine = create_engine(url)
self.engine = create_engine(url, **(engine_options or {}))
else:
raise ValueError('Need either "engine" or "url" defined')

Expand Down
3 changes: 2 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,5 @@
# If false, no module index is generated.
#latex_use_modindex = True

intersphinx_mapping = {'python': ('http://docs.python.org/', None)}
intersphinx_mapping = {'python': ('http://docs.python.org/', None),
'sqlalchemy': ('http://docs.sqlalchemy.org/en/latest/', None)}
6 changes: 6 additions & 0 deletions docs/versionhistory.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ Version history
To find out how to migrate your application from a previous version of
APScheduler, see the :doc:`migration section <migration>`.

3.5.0
-----

* Added the ``engine_options`` option to ``SQLAlchemyJobStore``


3.4.0
-----

Expand Down

4 comments on commit 51f76ae

@jkryanchou
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@gali-paz
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you make a new tag with this commit? it seems like version 3.5.0 is supposed to have it, but the version doesn't exist and one version before doesn't include it. thanks!

@agronholm
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have other changes lined up for v3.5.0. I will make a release when I'm done with those. The workaround for this particular issue is trivial so it shouldn't be a blocker for anyone.

@jkryanchou
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@agronholm 👍 Thanks~

Please sign in to comment.