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.

Files for sqlalchemy-function, version 0.0.5
Filename, size File type Python version Upload date Hashes
Filename, size sqlalchemy_function-0.0.5-py3-none-any.whl (4.5 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size sqlalchemy-function-0.0.5.tar.gz (3.3 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page