Apgorm
A fully type-checked asynchronous ORM wrapped around asyncpg. In the beta stage.
Install / Use
/learn @circuitsacul/ApgormREADME
apgorm
An asynchronous ORM wrapped around asyncpg. Examples can be found under examples/. Run examples with python -m examples.<example_name> (python -m examples.basic).
Please note that this library is not for those learning SQL or Postgres. Although the basic usage of apgorm is straightforward, you will run into problems, especially with migrations, if you don't understand regular SQL well.
Features
- Fairly straightforward and easy-to-use.
- Support for basic migrations.
- Protects against SQL-injection.
- Python-side converters and validators.
- Decent many-to-many support.
- Fully type-checked.
- Tested.
Limitations
- Limited column namespace. For example, you cannot have a column named
tablenamesince that is used to store the name of the model. - Only supports PostgreSQL with asyncpg.
- Migrations don't natively support field/table renaming or type changes, but you can still write your own migration with raw SQL.
- Converters only work on instances of models and when initializing the model.
- Models can only detect assignments. If
User.nicknamesis a list of nicknames, it won't detectuser.nicknames.append("new nick"). You need to douser.nicknames = user.nicknames + ["new nick"].
Basic Usage
Defining a model and database:
class User(apgorm.Model):
username = apgorm.types.VarChar(32).field()
email = apgorm.types.VarChar().nullablefield()
primary_key = (username,)
class Database(apgorm.Database):
users = User
Intializing the database:
db = Database(migrations_folder="path/to/migrations")
await db.connect(database="database name")
Creating & Applying migrations:
if db.must_create_migrations():
db.create_migrations()
if await db.must_apply_migrations():
await db.apply_migrations()
Basic create, fetch, update, and delete:
user = await User(username="Circuit").create()
print("Created user", user)
assert user == await User.fetch(username="Circuit")
user.email = "email@example.com"
await user.save()
await user.delete()
Related Skills
oracle
342.0kBest practices for using the oracle CLI (prompt + file bundling, engines, sessions, and file attachment patterns).
prose
342.0kOpenProse VM skill pack. Activate on any `prose` command, .prose files, or OpenProse mentions; orchestrates multi-agent workflows.
claude-opus-4-5-migration
84.7kMigrate prompts and code from Claude Sonnet 4.0, Sonnet 4.5, or Opus 4.1 to Opus 4.5
Command Development
84.7kThis skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
