<commit_before>---
layout: pattern
title: Transaction Script
folder: transaction-script
permalink: /patterns/transaction-script/
categories: Behavioral
tags:
 - Data access
---

## Intent
Transaction script(TS) is mainly used in small applications where nothing complex is done and bigger architecture's are not needed.

## Explanation
Real world example
> Your need is to be able to book a hotel room and also be able to cancel that booking.
> 

In plain words
> All logic related to booking a hotel room like checking room availability,
> calculate rates and update the database is done inside a single transaction script.
> Similar procedure is also needed for cancelling a room booking and all 
> that logic will be in another transaction script.

Programmatic example
<commit_msg>Update transaction-script/Readme.md<commit_after>---
layout: pattern
title: Transaction Script
folder: transaction-script
permalink: /patterns/transaction-script/
categories: Behavioral
tags:
 - Data access
---

## Intent
Transaction Script organizes business logic by procedures where each procedure handles a single request from the presentation.

## Explanation
Real world example
> Your need is to be able to book a hotel room and also be able to cancel that booking.
> 

In plain words
> All logic related to booking a hotel room like checking room availability,
> calculate rates and update the database is done inside a single transaction script.
> Similar procedure is also needed for cancelling a room booking and all 
> that logic will be in another transaction script.

Programmatic example

{'fraction_non_alphanumeric': 0.04914933837429111, 'fraction_numerical': 0.0, 'mean_word_length': 4.571929824561403, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4865505', 'n_tokens_mistral': 377, 'n_tokens_neox': 369, 'n_words': 215}