logicbank


Namelogicbank JSON
Version 1.20.8 PyPI version JSON
download
home_pagehttps://github.com/valhuber/logicbank
SummaryDeclare multi-table rules for SQLAlchemy update logic -- 40X more concise, Python for extensibility.
upload_time2024-09-27 20:56:52
maintainerNone
docs_urlNone
authorVal Huber
requires_python~=3.8
licenseBSD
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Logic Bank governs SQLAlchemy
update transaction logic - multi-table derivations, constraints,
and actions such as sending mail or messages. Logic consists of both:

* **Rules - 40X** more concise
using a spreadsheet-like paradigm, and

* **Python - control and extensibility,**
using standard tools and techniques

> The example described below is a _typical_ example of multi-table logic.
>
> You may find it helpful to begin with [this Tutorial, using a basic example](../../wiki/Tutorial).
>
>
> **Update - Jan 26, 2021:** You can use LogicBank for your own _existing_ projects.  For _new_ projects, the recommended approach is [**ApiLogicServer**](https://github.com/valhuber/ApiLogicServer#readme) - create a complete logic-enabled JSON:API for your database, and a admin app, with 1 command.

This readme contains:

1. [Background](#background)
    * [Why](#why---simple-cocktail-napkin-spec-explodes-into-massive-legacy-code) - problems addressed
    * [What](#what---declare-spreadsheet-like-rules---40x-more-concise) - what are spreadsheet-like rules
    * [How](#how---usage-and-operation-overview) - usage / operation overview
    * [Logic Execution](#logic-execution-add-order---watch-react-chain) - sample transaction execution, reuse and scalability
    * [Instant Web App](#an-agile-perspective) - built using [Flask App Builder Quickstart](https://github.com/valhuber/fab-quick-start/wiki)
1. [Install Instructions](#installation) - of Python and Logic Bank, with verify and run instructions
1. [Project Information](#project-information)


# Background

## Why - Simple Cocktail-Napkin Spec Explodes into Massive Legacy Code

If you've coded backend database logic - multi-table derivations and constraints -
you know how much work it is, and how tedious.  Whether you code it in
triggers and stored procedures, in ORM events, or UI controllers, it's a lot:
typically nearly half the effort for a database project.

It's also incredibly repetitive - you often get the feeling you're doing the same thing over and over.

And you're right.  It's because backend logic follows patterns of "what" is supposed to happen.
And your code is the "how".  Suddenly, a simple cocktail napkin specification explodes into a massive amount of legacy code:

<figure><img src="https://github.com/valhuber/LogicBank/blob/main/images/overview/rules-vs-code.png?raw=true"></figure>

Logic Bank was designed to make the cocktail napkin spec _executable_.

## What - Declare Spreadsheet-like Rules - 40X More Concise
Logic Bank introduces rules that are 40X more concise than legacy code.
The 5 rules below (lines 40-49) express the same logic as 200 lines of code [**(see them here)**](examples/nw/logic/legacy).  That's because rules are all about "what"
-- spreadsheet-like expressions that automate the tedious "how":

<figure><img src="https://github.com/valhuber/LogicBank/blob/main/images/overview/cocktail-logic-bank.png?raw=true"></figure>

### Standard Python - Declare, Extend, Manage
Logic Bank is fully integrated with Python:
* **Declare** rules in Python as shown above (more details in How, below)
* **Extend** rules with Python (rule on line 51 invokes the Python function on line 32)
* **Manage** logic using your existing IDE (PyCharm, VSCode etc for code completion, debugging, etc),
and source control tools and procedures

### Technology Evaluation
40X is... _large_ - do these results hold in practice?
See [here](../../wiki#technology-evaluation) for
additional background, and real world experience.


## How - Usage and Operation Overview
<figure><img src="https://github.com/valhuber/LogicBank/blob/main/images/architecture.png?raw=true"></figure>
Logic Bank operates as shown above:

 1. **Declare and Activate** (see example above):

    a. Create a ```declare_logic``` function (above, line 12),
    and declare your rules using ```Rule.``` (e.g., with IDE code completion)
 
    b. After opening your database, call ```activate```
    to register your rules, and establish Logic Bank as
    a listener for SQLAlchemy ```before_flush``` events
    
    
 2. Your application operates as usual: makes calls on `SQLAlchemy` for inserts, updates and deletes
    and issues `session.commit()`

    - By bundling transaction logic into SQLAlchemy data access, your logic
  is automatically shared, whether for hand-written code (Flask apps, APIs)
      

 3. The **Logic Bank** engine handles SQLAlchemy `before_flush` events on
`Mapped Tables`, so executes when you issue ```session.commit()```
    

 4. The logic engine operates much like a spreadsheet:
    - **watch** for changes at the attribute level
    - **react** by running rules that referenced changed attributes, which can
    - **chain** to still other attributes that refer to
_those_ changes.  Note these might be in different tables,
providing automation for _multi-table logic_

Logic does not apply to updates outside SQLAlchemy,
nor to SQLAlchemy batch updates or unmapped sql updates.

Let's see how logic operates on a typical, multi-table transaction.

### Logic Execution: Add Order - Watch, React, Chain

<figure><img src="https://github.com/valhuber/LogicBank/blob/main/images/check-credit.png?raw=true"></figure>


The `add_order` example illustrates how
__Watch / React / Chain__ operates to
check the Credit Limit as each OrderDetail is inserted:

1.  The `OrderDetail.UnitPrice` (copy, line 49) references Product, so inserts cause it to be copied
    
2.  `Amount` (formula, line 48) watches `UnitPrice`, so its new value recomputes `Amount`
    
3.  `AmountTotal` (sum, line 46) watches `Amount`, so `AmountTotal` is adjusted (more on adjustment, below)
    
4.  `Balance` (sum, line 43) watches `AmountTotal`, so it is adjusted
    
5.  And the Credit Limit constraint (line 40) is checked (exceptions are raised if constraints are violated, and the transaction is rolled back)
    
All of the dependency management to see which attributes have changed,
logic ordering, the SQL commands to read and adjust rows, and the chaining
are fully automated by the engine, based solely on the rules above.

### Spreadsheet-like Automatic Reuse
Just as a spreadsheet reacts
to inserts, updates and deletes to a summed column,
rules automate _adding_, _deleting_ and _updating_ orders.
This is how 5 rules represent the same logic as 200 lines of code.

Check out more examples:
* [**Ship Order**](../../wiki/Ship-Order) illustrates *cascade*, another form of multi-table logic
* [**Banking**](../../wiki/Sample-Project---Banking) is a complex transaction using the command pattern

### Scalability: Automatic Prune / Optimize logic
Scalability requires more than clustering - SQLs must be pruned
and optimized.  For example, the balance rule:
* is **pruned** if only a non-referenced column is altered (e.g., Shipping Address)
* is **optimized** into a 1-row _adjustment_ update instead of an
expensive SQL aggregate

For more on how logic automates and optimizes multi-table transactions,
[click here](../../wiki#scalability-automatic-pruning-and-optimization).


## An Agile Perspective
The core tenant of agile is

    Working software, driving collaboration, for rapid iterations

Here's how rules can help.

#### Working Software _Now_
The examples above illustrate how just a few rules can replace 
[pages of code](examples/nw/logic/legacy).


#### Iteration - Automatic Ordering
Rules are _self-ordering_ - they recognize their interdependencies,
and order their execution and database access (pruning, adjustments etc)
accordingly.  This means:

* order is independent - you can state the rules in any order
and get the same result

* maintenance is simple - just make changes, additions and deletions,
the engine will reorganize execution order and database access, automatically


# Installation
First, follow the instructions to verify / install Python, then install Logic Bank.

### Python Installation

The first section below verifies whether your Python environment is current.
The following section explains how to install a current Python environment.

#### Verify Pre-reqs: Python 3.8, virtualenv, pip3
Ensure you have these pre-reqs:
```
python --version
# requires 3.8 or higher (Relies on `from __future__ import annotations`, so requires Python 3.8)

pip --version
# version 19.2.3 or higher... you might be using pip3

pyenv --version
# 1.2.19 or higher
```
#### Install Python (if required)
If you are missing any, install them as described here.  Skip this step if your pre-reqs are fine.

To install Python:

* Python3.8 

   * Run the windows installer
      * Be sure to specify "add Python to Path"
   * On mac/Unix, consider [using homebrew](https://brew.sh/), as described
[here](https://opensource.com/article/19/5/python-3-default-mac#what-to-do)
   
* virtualenv - see [here](https://www.google.com/url?q=https%3A%2F%2Fpackaging.python.org%2Fguides%2Finstalling-using-pip-and-virtual-environments%2F%23creating-a-virtual-environment&sa=D&sntz=1&usg=AFQjCNEu-ZbYfqRMjNQ0D0DqU1mhFpDYmw)  (e.g.,  `pip install virtualenv`)
   * on PC, see [these instructions](https://pypi.org/project/pyenv-win/)

* An IDE - optional - any will do (I've used [PyCharm](https://www.jetbrains.com/pycharm/download) and [VSCode](https://code.visualstudio.com), install notes [here](https://github.com/valhuber/fab-quick-start/wiki/IDE-Setup)), though different install / generate / run instructions apply for running programs.

Issues?  [Try here](https://github.com/valhuber/fab-quick-start/wiki/Mac-Python-Install-Issues).


### Install LogicBank
This procedure installs the Logic Bank source code, including
examples you can explore.

> To use Logic Bank in your own project: `pip install LogicBank`

In your IDE or Command Line:

```
# optionally fork, and then (WARNING - remove hyphens if you download the zip)
git clone https://github.com/valhuber/LogicBank.git
cd LogicBank
# windows: python -m venv venv
virtualenv venv
# For windows: .\venv\Scripts\activate
source venv/bin/activate
pip install -r requirements.txt
```
> **Warning -** if you just download the zip, *be sure* to remove the hyphen from the name.

> **Warning -** if you use an IDE, be sure to activate the virtual environment, and verify you are running a proper version of Python.

### Verify and Run

#### Run the `nw/tests`
Run the `nw/tests` programs under your IDE or the
command line; start with `test_add_order` and `test_upd_order_shipped,`
and see the [walk-throughs here](../../wiki/home#logic-execution-watch-react-chain).
The tests use ```unittest``` - you can run them as follows:

```
cd examples/nw/tests
python -m unittest test_add_order.py
python test_add_order.py  # or, run it like this

python -m unittest discover -p "test*.py"  # run all tests
```

> Note: the console **log** depicts logic execution
>
> Log lines are long - consider copying them to a text
> editor to view with / without word wrap
> 
> Or, run in an IDE - they look [like this](../../wiki/home#debugging-standard-debugger-logic-logging).

## Next Steps

### Run the Tutorial

First, run the [**10 minute Tutorial**](../../wiki/Tutorial).
You will see how to create, run and debug a rule in a simple, running example.

### Explore Sample Transactions

Then, check out the [**Examples**](../../wiki/Examples) - note the **navigation bar** on the right.  Key samples:
* [**Ship Order**](../../wiki/Ship-Order) illustrates *cascade*, another form of multi-table logic
* [**Allocation**](../../wiki/Sample-Project---Allocation) illustrates *extensibility*,
providing a reusable pattern for a *provider* to allocate
to a set of *recipients*
* [**Banking**](../../wiki/Sample-Project---Banking) is a complex transaction using the command pattern
* [**Referential Integrity**](../../wiki/Referential-Integrity) illustrates referential integrity support


A good way to proceed is to
* Clear the log
* Run the test
* Review the log, and the rules that drove the processing


### Articles
There a few articles that provide some orientation to Logic Bank:
* [Extensible Rules](https://dzone.com/articles/logic-bank-now-extensible-drive-95-automation-even) - defining new rule types, using Python
* [Declarative](https://dzone.com/articles/agile-design-automation-how-are-rules-different-fr) - exploring _multi-statement_ declarative technology
* [Automate Business Logic With Logic Bank](https://dzone.com/articles/automate-business-logic-with-logic-bank) - general introduction, discussions of extensibility, manageability and scalability
* [Agile Design Automation With Logic Bank](https://dzone.com/articles/logical-data-indendence) - focuses on automation, design flexibility and agile iterations

### See also the [LogicBankExamples](https://github.com/valhuber/LogicBankExamples) project

The `Logic Bank Examples` [(setup instructions here)](../../wiki/Sample-Project---Setup)
contains the same examples, but _not_ the `logic_bank` engine source code.
It uses the logic engine via `pip install`, as you would for your own projects:

```
pip install logicbank
```
> This is **not required here**, and requires the same
> pre-reqs noted above



# Project Information

### Revisions

[Revisions](https://github.com/valhuber/LogicBank/wiki/Summary,-Update-History) are described here.


#### What's in the project
<figure><img src="https://github.com/valhuber/LogicBank/blob/main/images/logic-bank-project.png?raw=true"></figure>

Logic Bank consists of:

* Several test database systems - `nw,`  `banking`,
  `referential_integrity` and `payment_allocation`;
these contain

    * [Databases](examples/nw/db) sqlite (no install required) and models

    * [Test folders](examples/nw/tests) that run key transactions - just run the scripts
(note the logs)
    
    * [Logic](examples/nw/logic) - rules (and for `nw`,
    the manual `legacy` code for contrast to rules)
    
* The `nw` sample illustrates comparisons of Business logic, both
[by code](examples/nw/logic/legacy) and by rules (shown above).

* The `logic_bank` engine source code


#### Internals

To explore:

* Click [here](../../wiki/Explore-Logic-Bank)
    for install / operations procedures
    
* Click [here](../../wiki/Logic-Walkthrough) for a
    short overview of internal logic execution

#### Acknowledgements
There are many to thank:
* Tyler Band, for testing and the Banking example
* Max Tardiveau, for testing
* Nishanth Shyamsundar, for PC testing
* Michael Holleran, for collaboration
* Mike Bayer, for suggestions on leveraging Python typing and remarkable responsiveness
* Achim Götz, for reporting an issue in FAB Quick Start use of Logic Base
* Gloria, for many reviews... and golden patience

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/valhuber/logicbank",
    "name": "logicbank",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "~=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "Val Huber",
    "author_email": "valjhuber@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/ff/9e/d159d9b28d6144fc0c512257f571271687b9ad2b7d7757edc18e5daa5c75/logicbank-1.20.8.tar.gz",
    "platform": "any",
    "description": "Logic Bank governs SQLAlchemy\nupdate transaction logic - multi-table derivations, constraints,\nand actions such as sending mail or messages. Logic consists of both:\n\n* **Rules - 40X** more concise\nusing a spreadsheet-like paradigm, and\n\n* **Python - control and extensibility,**\nusing standard tools and techniques\n\n> The example described below is a _typical_ example of multi-table logic.\n>\n> You may find it helpful to begin with [this Tutorial, using a basic example](../../wiki/Tutorial).\n>\n>\n> **Update - Jan 26, 2021:** You can use LogicBank for your own _existing_ projects.  For _new_ projects, the recommended approach is [**ApiLogicServer**](https://github.com/valhuber/ApiLogicServer#readme) - create a complete logic-enabled JSON:API for your database, and a admin app, with 1 command.\n\nThis readme contains:\n\n1. [Background](#background)\n    * [Why](#why---simple-cocktail-napkin-spec-explodes-into-massive-legacy-code) - problems addressed\n    * [What](#what---declare-spreadsheet-like-rules---40x-more-concise) - what are spreadsheet-like rules\n    * [How](#how---usage-and-operation-overview) - usage / operation overview\n    * [Logic Execution](#logic-execution-add-order---watch-react-chain) - sample transaction execution, reuse and scalability\n    * [Instant Web App](#an-agile-perspective) - built using [Flask App Builder Quickstart](https://github.com/valhuber/fab-quick-start/wiki)\n1. [Install Instructions](#installation) - of Python and Logic Bank, with verify and run instructions\n1. [Project Information](#project-information)\n\n\n# Background\n\n## Why - Simple Cocktail-Napkin Spec Explodes into Massive Legacy Code\n\nIf you've coded backend database logic - multi-table derivations and constraints -\nyou know how much work it is, and how tedious.  Whether you code it in\ntriggers and stored procedures, in ORM events, or UI controllers, it's a lot:\ntypically nearly half the effort for a database project.\n\nIt's also incredibly repetitive - you often get the feeling you're doing the same thing over and over.\n\nAnd you're right.  It's because backend logic follows patterns of \"what\" is supposed to happen.\nAnd your code is the \"how\".  Suddenly, a simple cocktail napkin specification explodes into a massive amount of legacy code:\n\n<figure><img src=\"https://github.com/valhuber/LogicBank/blob/main/images/overview/rules-vs-code.png?raw=true\"></figure>\n\nLogic Bank was designed to make the cocktail napkin spec _executable_.\n\n## What - Declare Spreadsheet-like Rules - 40X More Concise\nLogic Bank introduces rules that are 40X more concise than legacy code.\nThe 5 rules below (lines 40-49) express the same logic as 200 lines of code [**(see them here)**](examples/nw/logic/legacy).  That's because rules are all about \"what\"\n-- spreadsheet-like expressions that automate the tedious \"how\":\n\n<figure><img src=\"https://github.com/valhuber/LogicBank/blob/main/images/overview/cocktail-logic-bank.png?raw=true\"></figure>\n\n### Standard Python - Declare, Extend, Manage\nLogic Bank is fully integrated with Python:\n* **Declare** rules in Python as shown above (more details in How, below)\n* **Extend** rules with Python (rule on line 51 invokes the Python function on line 32)\n* **Manage** logic using your existing IDE (PyCharm, VSCode etc for code completion, debugging, etc),\nand source control tools and procedures\n\n### Technology Evaluation\n40X is... _large_ - do these results hold in practice?\nSee [here](../../wiki#technology-evaluation) for\nadditional background, and real world experience.\n\n\n## How - Usage and Operation Overview\n<figure><img src=\"https://github.com/valhuber/LogicBank/blob/main/images/architecture.png?raw=true\"></figure>\nLogic Bank operates as shown above:\n\n 1. **Declare and Activate** (see example above):\n\n    a. Create a ```declare_logic``` function (above, line 12),\n    and declare your rules using ```Rule.``` (e.g., with IDE code completion)\n \n    b. After opening your database, call ```activate```\n    to register your rules, and establish Logic Bank as\n    a listener for SQLAlchemy ```before_flush``` events\n    \n    \n 2. Your application operates as usual: makes calls on `SQLAlchemy` for inserts, updates and deletes\n    and issues `session.commit()`\n\n    - By bundling transaction logic into SQLAlchemy data access, your logic\n  is automatically shared, whether for hand-written code (Flask apps, APIs)\n      \n\n 3. The **Logic Bank** engine handles SQLAlchemy `before_flush` events on\n`Mapped Tables`, so executes when you issue ```session.commit()```\n    \n\n 4. The logic engine operates much like a spreadsheet:\n    - **watch** for changes at the attribute level\n    - **react** by running rules that referenced changed attributes, which can\n    - **chain** to still other attributes that refer to\n_those_ changes.  Note these might be in different tables,\nproviding automation for _multi-table logic_\n\nLogic does not apply to updates outside SQLAlchemy,\nnor to SQLAlchemy batch updates or unmapped sql updates.\n\nLet's see how logic operates on a typical, multi-table transaction.\n\n### Logic Execution: Add Order - Watch, React, Chain\n\n<figure><img src=\"https://github.com/valhuber/LogicBank/blob/main/images/check-credit.png?raw=true\"></figure>\n\n\nThe `add_order` example illustrates how\n__Watch / React / Chain__ operates to\ncheck the Credit Limit as each OrderDetail is inserted:\n\n1.  The `OrderDetail.UnitPrice` (copy, line 49) references Product, so inserts cause it to be copied\n    \n2.  `Amount` (formula, line 48) watches `UnitPrice`, so its new value recomputes `Amount`\n    \n3.  `AmountTotal` (sum, line 46) watches `Amount`, so `AmountTotal` is adjusted (more on adjustment, below)\n    \n4.  `Balance` (sum, line 43) watches `AmountTotal`, so it is adjusted\n    \n5.  And the Credit Limit constraint (line 40) is checked (exceptions are raised if constraints are violated, and the transaction is rolled back)\n    \nAll of the dependency management to see which attributes have changed,\nlogic ordering, the SQL commands to read and adjust rows, and the chaining\nare fully automated by the engine, based solely on the rules above.\n\n### Spreadsheet-like Automatic Reuse\nJust as a spreadsheet reacts\nto inserts, updates and deletes to a summed column,\nrules automate _adding_, _deleting_ and _updating_ orders.\nThis is how 5 rules represent the same logic as 200 lines of code.\n\nCheck out more examples:\n* [**Ship Order**](../../wiki/Ship-Order) illustrates *cascade*, another form of multi-table logic\n* [**Banking**](../../wiki/Sample-Project---Banking) is a complex transaction using the command pattern\n\n### Scalability: Automatic Prune / Optimize logic\nScalability requires more than clustering - SQLs must be pruned\nand optimized.  For example, the balance rule:\n* is **pruned** if only a non-referenced column is altered (e.g., Shipping Address)\n* is **optimized** into a 1-row _adjustment_ update instead of an\nexpensive SQL aggregate\n\nFor more on how logic automates and optimizes multi-table transactions,\n[click here](../../wiki#scalability-automatic-pruning-and-optimization).\n\n\n## An Agile Perspective\nThe core tenant of agile is\n\n    Working software, driving collaboration, for rapid iterations\n\nHere's how rules can help.\n\n#### Working Software _Now_\nThe examples above illustrate how just a few rules can replace \n[pages of code](examples/nw/logic/legacy).\n\n\n#### Iteration - Automatic Ordering\nRules are _self-ordering_ - they recognize their interdependencies,\nand order their execution and database access (pruning, adjustments etc)\naccordingly.  This means:\n\n* order is independent - you can state the rules in any order\nand get the same result\n\n* maintenance is simple - just make changes, additions and deletions,\nthe engine will reorganize execution order and database access, automatically\n\n\n# Installation\nFirst, follow the instructions to verify / install Python, then install Logic Bank.\n\n### Python Installation\n\nThe first section below verifies whether your Python environment is current.\nThe following section explains how to install a current Python environment.\n\n#### Verify Pre-reqs: Python 3.8, virtualenv, pip3\nEnsure you have these pre-reqs:\n```\npython --version\n# requires 3.8 or higher (Relies on `from __future__ import annotations`, so requires Python 3.8)\n\npip --version\n# version 19.2.3 or higher... you might be using pip3\n\npyenv --version\n# 1.2.19 or higher\n```\n#### Install Python (if required)\nIf you are missing any, install them as described here.  Skip this step if your pre-reqs are fine.\n\nTo install Python:\n\n* Python3.8 \n\n   * Run the windows installer\n      * Be sure to specify \"add Python to Path\"\n   * On mac/Unix, consider [using homebrew](https://brew.sh/), as described\n[here](https://opensource.com/article/19/5/python-3-default-mac#what-to-do)\n   \n* virtualenv - see [here](https://www.google.com/url?q=https%3A%2F%2Fpackaging.python.org%2Fguides%2Finstalling-using-pip-and-virtual-environments%2F%23creating-a-virtual-environment&sa=D&sntz=1&usg=AFQjCNEu-ZbYfqRMjNQ0D0DqU1mhFpDYmw)  (e.g.,  `pip install virtualenv`)\n   * on PC, see [these instructions](https://pypi.org/project/pyenv-win/)\n\n* An IDE - optional - any will do (I've used [PyCharm](https://www.jetbrains.com/pycharm/download) and [VSCode](https://code.visualstudio.com), install notes [here](https://github.com/valhuber/fab-quick-start/wiki/IDE-Setup)), though different install / generate / run instructions apply for running programs.\n\nIssues?  [Try here](https://github.com/valhuber/fab-quick-start/wiki/Mac-Python-Install-Issues).\n\n\n### Install LogicBank\nThis procedure installs the Logic Bank source code, including\nexamples you can explore.\n\n> To use Logic Bank in your own project: `pip install LogicBank`\n\nIn your IDE or Command Line:\n\n```\n# optionally fork, and then (WARNING - remove hyphens if you download the zip)\ngit clone https://github.com/valhuber/LogicBank.git\ncd LogicBank\n# windows: python -m venv venv\nvirtualenv venv\n# For windows: .\\venv\\Scripts\\activate\nsource venv/bin/activate\npip install -r requirements.txt\n```\n> **Warning -** if you just download the zip, *be sure* to remove the hyphen from the name.\n\n> **Warning -** if you use an IDE, be sure to activate the virtual environment, and verify you are running a proper version of Python.\n\n### Verify and Run\n\n#### Run the `nw/tests`\nRun the `nw/tests` programs under your IDE or the\ncommand line; start with `test_add_order` and `test_upd_order_shipped,`\nand see the [walk-throughs here](../../wiki/home#logic-execution-watch-react-chain).\nThe tests use ```unittest``` - you can run them as follows:\n\n```\ncd examples/nw/tests\npython -m unittest test_add_order.py\npython test_add_order.py  # or, run it like this\n\npython -m unittest discover -p \"test*.py\"  # run all tests\n```\n\n> Note: the console **log** depicts logic execution\n>\n> Log lines are long - consider copying them to a text\n> editor to view with / without word wrap\n> \n> Or, run in an IDE - they look [like this](../../wiki/home#debugging-standard-debugger-logic-logging).\n\n## Next Steps\n\n### Run the Tutorial\n\nFirst, run the [**10 minute Tutorial**](../../wiki/Tutorial).\nYou will see how to create, run and debug a rule in a simple, running example.\n\n### Explore Sample Transactions\n\nThen, check out the [**Examples**](../../wiki/Examples) - note the **navigation bar** on the right.  Key samples:\n* [**Ship Order**](../../wiki/Ship-Order) illustrates *cascade*, another form of multi-table logic\n* [**Allocation**](../../wiki/Sample-Project---Allocation) illustrates *extensibility*,\nproviding a reusable pattern for a *provider* to allocate\nto a set of *recipients*\n* [**Banking**](../../wiki/Sample-Project---Banking) is a complex transaction using the command pattern\n* [**Referential Integrity**](../../wiki/Referential-Integrity) illustrates referential integrity support\n\n\nA good way to proceed is to\n* Clear the log\n* Run the test\n* Review the log, and the rules that drove the processing\n\n\n### Articles\nThere a few articles that provide some orientation to Logic Bank:\n* [Extensible Rules](https://dzone.com/articles/logic-bank-now-extensible-drive-95-automation-even) - defining new rule types, using Python\n* [Declarative](https://dzone.com/articles/agile-design-automation-how-are-rules-different-fr) - exploring _multi-statement_ declarative technology\n* [Automate Business Logic With Logic Bank](https://dzone.com/articles/automate-business-logic-with-logic-bank) - general introduction, discussions of extensibility, manageability and scalability\n* [Agile Design Automation With Logic Bank](https://dzone.com/articles/logical-data-indendence) - focuses on automation, design flexibility and agile iterations\n\n### See also the [LogicBankExamples](https://github.com/valhuber/LogicBankExamples) project\n\nThe `Logic Bank Examples` [(setup instructions here)](../../wiki/Sample-Project---Setup)\ncontains the same examples, but _not_ the `logic_bank` engine source code.\nIt uses the logic engine via `pip install`, as you would for your own projects:\n\n```\npip install logicbank\n```\n> This is **not required here**, and requires the same\n> pre-reqs noted above\n\n\n\n# Project Information\n\n### Revisions\n\n[Revisions](https://github.com/valhuber/LogicBank/wiki/Summary,-Update-History) are described here.\n\n\n#### What's in the project\n<figure><img src=\"https://github.com/valhuber/LogicBank/blob/main/images/logic-bank-project.png?raw=true\"></figure>\n\nLogic Bank consists of:\n\n* Several test database systems - `nw,`  `banking`,\n  `referential_integrity` and `payment_allocation`;\nthese contain\n\n    * [Databases](examples/nw/db) sqlite (no install required) and models\n\n    * [Test folders](examples/nw/tests) that run key transactions - just run the scripts\n(note the logs)\n    \n    * [Logic](examples/nw/logic) - rules (and for `nw`,\n    the manual `legacy` code for contrast to rules)\n    \n* The `nw` sample illustrates comparisons of Business logic, both\n[by code](examples/nw/logic/legacy) and by rules (shown above).\n\n* The `logic_bank` engine source code\n\n\n#### Internals\n\nTo explore:\n\n* Click [here](../../wiki/Explore-Logic-Bank)\n    for install / operations procedures\n    \n* Click [here](../../wiki/Logic-Walkthrough) for a\n    short overview of internal logic execution\n\n#### Acknowledgements\nThere are many to thank:\n* Tyler Band, for testing and the Banking example\n* Max Tardiveau, for testing\n* Nishanth Shyamsundar, for PC testing\n* Michael Holleran, for collaboration\n* Mike Bayer, for suggestions on leveraging Python typing and remarkable responsiveness\n* Achim G\u00f6tz, for reporting an issue in FAB Quick Start use of Logic Base\n* Gloria, for many reviews... and golden patience\n",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "Declare multi-table rules for SQLAlchemy update logic -- 40X more concise, Python for extensibility.",
    "version": "1.20.8",
    "project_urls": {
        "Docs": "https://github.com/valhuber/logicbank/wiki",
        "Homepage": "https://github.com/valhuber/logicbank"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a9db1e42df5d938a883af729e36f73989d7e67dc5df54647aeea52e6f1136063",
                "md5": "b00b5b453ea9e6683feeea9e5b44f13f",
                "sha256": "0fdf916e400dd1416449ea1f452837c070157f02d98e5559f0cab52408c16d0d"
            },
            "downloads": -1,
            "filename": "logicbank-1.20.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b00b5b453ea9e6683feeea9e5b44f13f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "~=3.8",
            "size": 53906,
            "upload_time": "2024-09-27T20:56:50",
            "upload_time_iso_8601": "2024-09-27T20:56:50.996041Z",
            "url": "https://files.pythonhosted.org/packages/a9/db/1e42df5d938a883af729e36f73989d7e67dc5df54647aeea52e6f1136063/logicbank-1.20.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ff9ed159d9b28d6144fc0c512257f571271687b9ad2b7d7757edc18e5daa5c75",
                "md5": "55c5dc27c6f27773472823185a1fea39",
                "sha256": "548e40033e091ca36a089fba72750158c27345ea863f4e007df7ecee3ed5440e"
            },
            "downloads": -1,
            "filename": "logicbank-1.20.8.tar.gz",
            "has_sig": false,
            "md5_digest": "55c5dc27c6f27773472823185a1fea39",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "~=3.8",
            "size": 49581,
            "upload_time": "2024-09-27T20:56:52",
            "upload_time_iso_8601": "2024-09-27T20:56:52.646420Z",
            "url": "https://files.pythonhosted.org/packages/ff/9e/d159d9b28d6144fc0c512257f571271687b9ad2b7d7757edc18e5daa5c75/logicbank-1.20.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-27 20:56:52",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "valhuber",
    "github_project": "logicbank",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "logicbank"
}
        
Elapsed time: 0.35298s