Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
bin
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

duosql

An easy way to demonstrate database transactions.

Prerequisite

  • Python 3.5+
  • tmux

Install

pip3 install duosql

Usage

  1. Create a .duo script file. For example:
# connect command
connect: sqlite3 demo.sqlite3

# create table and populate data
left: DROP TABLE IF EXISTS person;
left: CREATE TABLE person (id INTEGER, name VARCHAR(255) NOT NULL, age INTEGER NOT NULL, PRIMARY KEY (id));
left: INSERT INTO person (name, age) VALUES ('Alice', 30);

# start left transaction and update a row
left: BEGIN;
left: UPDATE person SET age = 31 WHERE id = 1;

# update the same row on the right side and then stuck
right: PRAGMA busy_timeout = 100000;
right: UPDATE person SET age = 40 WHERE id = 1;

# continue left transaction and finally rollback so the right side can finish
left: UPDATE person SET age = 32 WHERE id = 1;
left: UPDATE person SET age = 33 WHERE id = 1;
left: ROLLBACK;
  1. Run duosql <script-file>.

  2. Watch.

About

An easy way to demonstrate database transactions.

Resources

License

Releases

No releases published

Packages

No packages published