Bases and Mixins to store functions for later execution
Project description
SQLAlchemy-Function
SQLAlchemy-Function defines a SQLALchemy Mixin for creating Function
models.
A Function
model has a parent (optional), a function, arguments, and keyword arguments. When called, the Function
model executes its function, passing in its parent (if applicable), its arguments, and its keyword arguments.
Example
Suppose we have a function, foo
, which we want to store. We also want to store the arguments and keyword arguments with which we will later execute foo
.
After setup, we can achieve this with the following:
def foo(*args, **kwargs):
print('My arguments are:', args)
print('My keyword arguments are:', kwargs)
return 'hello world'
f = Function(func=foo, args=['hello moon'], kwargs={'hello': 'star'})
session.add(f)
session.commit()
print(f())
Output:
My arguments are: ('hello moon',)
My keyword arguments are: {'hello': 'star'}
hello world
Documentation
You can find the latest documentation at https://dsbowen.github.io/sqlalchemy-function.
License
Publications which use this software should include the following citation for SQLAlchemy-Function and its dependency, SQLAlchemy-Mutable:
Bowen, D.S. (2019). SQLAlchemy-Function [Computer software]. https://dsbowen.github.io/sqlalchemy-function.
Bowen, D.S. (2019). SQLAlchemy-Mutable [Computer software]. https://dsbowen.github.io/sqlalchemy-mutable.
This project is licensed under the MIT License LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for sqlalchemy-function-0.0.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7479e7670518556b014ad87a580cebcd5aefac65f13beff14d2d7a99bbad5088 |
|
MD5 | 318372bfa71df0fab579094862506d0c |
|
BLAKE2b-256 | 89c1b22767c18979af5f29c7a75da0e18d25e7ba355a14eb3bc1bfccc4cc016b |
Hashes for sqlalchemy_function-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63d137da132b2a6f6ef6b8d859d0f8690b2c4d42577ea73b772c986cf9dfa646 |
|
MD5 | 1aac21bca4e35e8cbf27c3036052c517 |
|
BLAKE2b-256 | fe0ec8330c45d5888aeac6704803a409a2782b059c346e8e2ea484998812bba4 |