### Run Unit Tests with Tox Source: https://pypi.org/project/caribou Install dependencies and run unit tests using uv and tox. ```bash uv sync tox ``` -------------------------------- ### Install Caribou Package Source: https://pypi.org/project/caribou Use pip to install the Caribou package. ```bash pip install caribou ``` -------------------------------- ### Run Caribou Migrations via CLI Source: https://pypi.org/project/caribou Execute migrations using the Caribou command line tool. The 'upgrade' command applies pending migrations, while 'downgrade' reverts to a specified version. ```bash $ caribou upgrade db.sqlite . upgrading db [db.sqlite] to most recent version upgraded [db.sqlite] successfully to version [20091115140758] # if you want to revert your changes, use the downgrade command: $ caribou downgrade db.sqlite . 0 downgrading db [db.sqlite] to version [0] downgraded [db.sqlite] successfully to version [0] ``` -------------------------------- ### Module-Based Migrations with Caribou Source: https://pypi.org/project/caribou For packaged applications (e.g., with PyInstaller), use module-based migration discovery. Pass a list of imported migration modules directly to 'upgrade()' and 'downgrade()'. ```python import caribou from myapp.migrations import v20240101120000_create_users, v20240215090000_add_scores modules = [v20240101120000_create_users, v20240215090000_add_scores] # upgrade using modules caribou.upgrade("my.db", modules) # downgrade using modules caribou.downgrade("my.db", modules, "0") ``` -------------------------------- ### Create a Caribou Migration Source: https://pypi.org/project/caribou Use the Caribou command line tool to generate a new migration file. This command creates a Python file in the current directory with a timestamped name. ```bash $ caribou create my_first_migration created migration ./v20091115140758_my_first_migration.py ``` -------------------------------- ### Run Caribou Migrations Programmatically Source: https://pypi.org/project/caribou Integrate Caribou migrations directly into your Python application. Use the 'caribou.upgrade' and 'caribou.downgrade' functions, specifying the database file and migration directory. ```python """ An example illustrating how to run a migration programmatically. """ import caribou db = 'db.sqlite' migrations_dir = '/path/to/migrations/dir' version = '20091115140758' # upgrade to most recent version caribou.upgrade(db, migrations_dir) # upgrade to a specific version caribou.upgrade(db, migrations_dir, version) # downgrade to a specific version caribou.downgrade(db, migrations_dir, version) ``` -------------------------------- ### Edit a Caribou Migration File Source: https://pypi.org/project/caribou Migration files are plain Python scripts. Define 'upgrade' and 'downgrade' functions to manage schema changes. The 'connection' object is a standard sqlite3 database connection. ```python """ An example of a Caribou migration file. """ def upgrade(connection): # connection is a plain old sqlite3 database connection sql = """ create table animals ( name TEXT , status TEXT ) "" " connection.execute(sql) animals = [ ('caribou', 'least concerned') , ('bengal tiger', 'threatened') , ('eastern elk', 'extinct') ] sql = 'insert into animals values (?, ?)' for name, status in animals: connection.execute(sql, [name, status]) connection.commit() def downgrade(connection): connection.execute('drop table animals') ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.