Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sqlalchemy-function-0.0.4.tar.gz (3.3 kB view hashes)

Uploaded Source

Built Distribution

sqlalchemy_function-0.0.4-py3-none-any.whl (4.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page