Skip to content

johnlinp/duosql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published