MCPcopy Index your code
hub / github.com/NyxCode/ormx

github.com/NyxCode/ormx @v0.11

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.11 ↗ · + Follow
106 symbols 178 edges 27 files 21 documented · 20%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

ormx

lightweight macros for sqlx

Crates.io version

chat

docs.rs docs

Download

getting started

Add ormx and sqlx to your Cargo.toml

[dependencies.ormx]
version = "0.11"
features = ["mysql"]

[dependencies.sqlx]
version = "0.8"
default-features = false
features = ["macros", "mysql", "runtime-tokio-rustls"]

Right now, ormx supports mysql, mariadb and postgres.

what does it do?

ormx provides macros for generating commonly used sql queries at compile time.
ormx is meant to be used together with sqlx. Everything it generates uses sqlx::query! under the hood, so every generated query will be checked against your database at compile time.

what doesn't it do?

ormx is not a full-fledged ORM nor a query builder. For everything except simple CRUD, you can always just use sqlx.

it is required that every table contains an id column, which uniquely identifies a row. probably, you would want to use an auto-incrementing integer for this. this is a central requirement of ormx, and if your table does not fulfill this requirement, ormx is not what you are looking for.

help

if you encounter an issue or have questions, feel free to ask in #ormx on the sqlx discord.
The documentation currently is not what it should be, so don't be afraid to ask for help.

postgres example

mariadb example

mysql example

features

  • mysql - enable support for mysql/mariadb
  • postgres - enable support for postgres

migration guide for 0.7

Since 0.7, id columns are not special anymore - if they are generated by the database, you must annotate them with #[ormx(default)].

a note on reborrowing

if you run into the issue that the compiler tells you that you can't re-use a &mut Connection because
- use of moved value and - move occurs because 'con' has type '&mut Connection', which does not implement the 'Copy' trait

you'll have to manually reborrow the connection with &mut *con.

Extension points exported contracts — how you extend this code

Backend (Interface)
(no doc) [3 implementers]
ormx-macros/src/backend/mod.rs
SendFuture (Interface)
Ridiculous workaround for [#100013](https://github.com/rust-lang/rust/issues/100013#issuecomment-2210995259). [1 implementers]
ormx/src/lib.rs
Table (Interface)
A database table in which each row is identified by a unique ID.
ormx/src/lib.rs
Patch (Interface)
A type which can be used to "patch" a row, updating multiple fields at once.
ormx/src/lib.rs
Insert (Interface)
A type which can be inserted as a row into the database.
ormx/src/lib.rs
Delete (Interface)
(no doc)
ormx/src/lib.rs

Core symbols most depended-on inside this repo

set_once
called by 19
ormx-macros/src/utils.rs
insertable_fields
called by 6
ormx-macros/src/table/mod.rs
default_fields
called by 6
ormx-macros/src/table/mod.rs
missing_attr
called by 5
ormx-macros/src/utils.rs
insert
called by 4
ormx/src/lib.rs
column
called by 3
ormx-macros/src/table/mod.rs
or_fallback
called by 3
ormx-macros/src/table/mod.rs
patch
called by 3
ormx/src/lib.rs

Shape

Function 37
Method 36
Class 20
Enum 7
Interface 6

Languages

Rust100%

Modules by API surface

ormx/src/lib.rs13 symbols
ormx-macros/src/table/mod.rs12 symbols
ormx-macros/src/attrs.rs9 symbols
ormx-macros/src/backend/common/mod.rs8 symbols
ormx-macros/src/backend/mod.rs7 symbols
ormx-macros/src/backend/common/table.rs7 symbols
example-postgres/src/main.rs7 symbols
ormx-macros/src/backend/postgres/mod.rs5 symbols
ormx-macros/src/backend/mysql/mod.rs5 symbols
ormx-macros/src/backend/mysql/insert.rs5 symbols
ormx-macros/src/backend/mariadb/mod.rs5 symbols
ormx-macros/src/patch/mod.rs4 symbols

Datastores touched

(mysql)Database · 1 repos
ormxDatabase · 1 repos
ormxDatabase · 1 repos

For agents

$ claude mcp add ormx \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact