Skip to main content
What this builds. A full create / fetch / list / rename / duplicate / delete walk on Table, run through the a* async methods (anew, afetch, alist, aupdate, aduplicate, adelete) inside an asyncio.run(...) event loop. You’ll end up with. A new table that’s been renamed and duplicated, then both copies cleanly deleted — nothing left behind in your account.
"""Run the full Table lifecycle through the async (a*) methods."""

import asyncio

from vectorshift.table import Table


async def main() -> None:
    t = await Table.anew(name="SDK Tables Async Demo")
    print(f"1. Created Table (async): {t.name!r} (id={t.id})")

    fetched = await Table.afetch(id=t.id)
    print(f"2. Fetched by id (async): {fetched.name!r}")

    tables = await Table.alist(limit=10)
    found = any(x.id == t.id for x in tables)
    print(f"3. Listed Tables (async): {len(tables)} total, found ours: {found}")

    await t.aupdate(name="SDK Tables Async Demo (renamed)")
    print("4. Renamed (async).")

    copy = await t.aduplicate(new_name="SDK Tables Async Demo (copy)")
    print(f"5. Duplicated (async): {copy.name!r}")

    await copy.adelete()
    await t.adelete()
    print("6. Deleted both (async).\n\nDone.")


if __name__ == "__main__":
    asyncio.run(main())

Expected output

1. Created Table (async): 'SDK Tables Async Demo' (id=...)
2. Fetched by id (async): 'SDK Tables Async Demo'
3. Listed Tables (async): ... total, found ours: True
4. Renamed (async).
5. Duplicated (async): 'SDK Tables Async Demo (copy)'
6. Deleted both (async).

Done.

See also

Sync CRUD

The blocking version of this walk.

End-to-end walkthrough

Build a vendor scorecard from schema to export.

Reference

Every public method.