asyncpg-trek

raw JSON →
0.4.0 verified Fri May 01 auth: no python

A simple migrations system for asyncpg and aiosqlite. Current version 0.4.0, supports Python 3.8+. Release cadence is irregular, with few releases since inception.

pip install asyncpg-trek
error ModuleNotFoundError: No module named 'aiosqlite'
cause Using aiosqlite backend without installing aiosqlite.
fix
pip install aiosqlite
error asyncpg.exceptions.PostgresError: relation 'asyncpg_trek_migrations' does not exist
cause The migrations tracking table was not created; migration script not run or connection without schema.
fix
Ensure you call asyncpg_trek.migrate() before running migrations, and verify the database schema is accessible.
breaking In 0.4.0, the aiosqlite backend was added, potentially changing import paths or the SupportsBackend interface.
fix Check if you use custom backends; update imports if needed.
breaking In 0.3.0, SupportsBackend was split into SupportsBackend and SupportsBackendExecutor, breaking custom backends.
fix If you implemented a custom backend, split your class according to the new interfaces.
deprecated The default backend may be deprecated in the future as aiosqlite support matures.
fix No immediate action needed.

Run migrations using an asyncpg connection and a local 'migrations' directory.

import asyncio
import asyncpg_trek
import os

async def main():
    conn = await asyncpg.connect(
        user='postgres',
        password=os.environ.get('PGPASSWORD', ''),
        database='test'
    )
    await asyncpg_trek.migrate(conn, migrations_path='./migrations')
    await conn.close()

asyncio.run(main())