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.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea2bb58f7ea1d00983473361e23942c7d9287676ed403ab26f1d9c8c5dd4d150 |
|
MD5 | 132d317484d8a088bc9cd921ccbe13a8 |
|
BLAKE2b-256 | 7f1cfa84d09c0785d1db6cbe5cfb328b1d8438b467b5a3215255852238fa171b |
Hashes for sqlalchemy_function-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35d00bc075e1939467ce1f7ba3a6b735342f03d6c4eb3a75d3a6617fbfd2b0c0 |
|
MD5 | cf7f4f4944f38fc0581c5b61d5fd559f |
|
BLAKE2b-256 | fc48de47c6f16d1e419bfc7aa67e8207b51383ec2bf65e304365650fc3ef4c2d |