SQLAlchemy 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://github.com/dsbowen/sqlalchemy-functionv
Bowen, D.S. (2019). SQLAlchemy-Mutable [Computer software]. https://github.com/dsbowen/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.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f946a0095306ed1192f36862808931fa373115113587f3efcc3d37fe1a461e9 |
|
MD5 | 9f9b2f894ce169935571c854362bb8f6 |
|
BLAKE2b-256 | f51af67841d8692267682df7f38e21d390162b8bef6c3b51ffcb1c135d853b1a |
Hashes for sqlalchemy_function-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e196f09491d2ee8ebed111774b63cb14ae96c58c4c1aa5c286cd744a1077361 |
|
MD5 | b53455928adeb819ef8d70a8bfd6378c |
|
BLAKE2b-256 | edc709cec8e2788b4b6bd3f2e08d095c76c35d16b50acc93ce1a604ddd2a9aef |