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.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d759b2f9d862ed5ba6e38d32d2ac8fd3ade3d0fdd6ce9d47db35a3eafdc9103c |
|
MD5 | cd9f38338b53d8f41e812632deb40a37 |
|
BLAKE2b-256 | f9ffeb5fac4e5fcf2a9dfecaf696c6792f0ca58b6ae2b92b89a6d8c8e19f6e89 |
Hashes for sqlalchemy_function-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 52ef398111b1a787c90f31250e11f7ed65a4b04ee2ed21cf5764e9bc1ad19197 |
|
MD5 | 71851d260e0f7f1e32d01bf4a881ba28 |
|
BLAKE2b-256 | 09e579039345c48f5d1ec368b91436b970bb2dc86cd4f5567e52a7dff85ec320 |