# go-xorm/xorm

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/go-xorm-xorm).**

6,628 stars · 742 forks · Go · BSD-3-Clause · archived

## Links

- GitHub: https://github.com/go-xorm/xorm
- awesome-repositories: https://awesome-repositories.com/repository/go-xorm-xorm.md

## Topics

`golang` `mssql` `mysql` `orm` `postgres` `postgresql` `sqlite` `tidb`

## Description

xorm is a relational mapper and object-relational mapping tool for Go. It translates Go structures into SQL queries and maps database rows back into native objects, providing a multi-dialect database driver that supports MySQL, PostgreSQL, SQLite, Oracle, SQL Server, and TiDB.

The project features a read-write splitting manager that routes modification requests to a primary database and read requests to replicas. It includes a database schema synchronizer to automatically align table structures and indexes with application data models, as well as a fluent SQL query builder for constructing complex filtered queries and joins.

The framework covers broad capability areas including high-level and raw CRUD operations, atomic transaction management, and memory-based caching for query results and objects. It also provides data integrity tools such as version-based optimistic locking, lifecycle hooks for custom operation logic, and result set streaming for handling large datasets.

Operational visibility is provided through database operation logging and syslog integration.

## Tags

### Data & Databases

- [CRUD Operations](https://awesome-repositories.com/f/data-databases/crud-operations.md) — Provides a high-level interface for performing standard create, read, update, and delete operations. ([source](https://github.com/go-xorm/xorm/blob/master/doc.go))
- [Object-Relational Mapping](https://awesome-repositories.com/f/data-databases/object-relational-mapping.md) — Provides a core mapping layer that converts relational database rows into native Go structures. ([source](https://github.com/go-xorm/xorm/blob/master/doc.go))
- [Relational Database Integrations](https://awesome-repositories.com/f/data-databases/relational-database-integrations.md) — Integrates Go applications with multiple relational databases including MySQL, PostgreSQL, SQLite, Oracle, and SQL Server.
- [Automatic Table Synchronizers](https://awesome-repositories.com/f/data-databases/automatic-table-synchronizers.md) — Aligns database table structures and indexes with application data models automatically. ([source](https://github.com/go-xorm/xorm/blob/master/session_test.go))
- [Column Mappings](https://awesome-repositories.com/f/data-databases/column-mappings.md) — Defines column properties and constraints using structural tags on Go data objects. ([source](https://github.com/go-xorm/xorm/blob/master/tag.go))
- [MySQL Connectors](https://awesome-repositories.com/f/data-databases/database-connectivity/mysql-connectors.md) — Implements a specialized driver for translating object queries into MySQL-compatible SQL syntax. ([source](https://github.com/go-xorm/xorm/blob/master/dialect_mysql.go))
- [Oracle Connectors](https://awesome-repositories.com/f/data-databases/database-connectivity/oracle-connectors.md) — Provides a specialized driver to execute compatible queries for Oracle relational databases. ([source](https://github.com/go-xorm/xorm/blob/master/dialect_oracle.go))
- [Database Dialects](https://awesome-repositories.com/f/data-databases/database-dialects.md) — Provides a multi-dialect driver layer supporting various database engines with specific syntax handling.
- [Database Schema Managers](https://awesome-repositories.com/f/data-databases/database-schema-managers.md) — Automatically synchronizes database table structures and indexes with application data models.
- [Fluent Query Construction](https://awesome-repositories.com/f/data-databases/expression-based-data-querying/fluent-query-apis/sql-syntax-tree-construction/fluent-query-construction.md) — Offers a fluent programmatic interface for constructing complex SQL queries and joins.
- [Fluent Query Builders](https://awesome-repositories.com/f/data-databases/fluent-query-builders.md) — Implements a chainable fluent interface for constructing complex database queries.
- [Query Condition Builders](https://awesome-repositories.com/f/data-databases/query-condition-builders.md) — Provides an API for constructing complex SQL WHERE clauses and filtering criteria. ([source](https://github.com/go-xorm/xorm/blob/master/session_cond_test.go))
- [Raw SQL Execution](https://awesome-repositories.com/f/data-databases/raw-sql-execution.md) — Supports executing custom raw SQL statements alongside high-level object-relational mapping. ([source](https://github.com/go-xorm/xorm#readme))
- [Read-Write Splitting](https://awesome-repositories.com/f/data-databases/read-write-splitting.md) — Routes database operations to different servers by splitting read requests to replicas and write requests to the primary. ([source](https://github.com/go-xorm/xorm#readme))
- [Read Load Balancers](https://awesome-repositories.com/f/data-databases/replica-load-balancers/read-load-balancers.md) — Distributes read queries across multiple database replicas using random, round-robin, or weighted policies. ([source](https://github.com/go-xorm/xorm/blob/master/engine_group_policy.go))
- [Schema Synchronizers](https://awesome-repositories.com/f/data-databases/schema-synchronizers.md) — Provides a tool to automatically align database schemas with application data models.
- [Dialect-Specific SQL Generation](https://awesome-repositories.com/f/data-databases/sql-generators/dialect-specific-sql-generation.md) — Translates abstract query operations into specific SQL syntax for MySQL, PostgreSQL, SQLite, Oracle, and SQL Server.
- [SQL ORMs](https://awesome-repositories.com/f/data-databases/sql-orms.md) — Acts as a full-featured relational mapper translating Go structures into SQL queries and vice versa.
- [Fluent Interfaces](https://awesome-repositories.com/f/data-databases/sql-query-interfaces/fluent-interfaces.md) — Offers a fluent interface for constructing complex SQL statements through method chaining.
- [Table Joining Operations](https://awesome-repositories.com/f/data-databases/table-data-processing/table-joining-operations.md) — Combines data from multiple tables using various join types based on related columns. ([source](https://github.com/go-xorm/xorm/blob/master/session_find_test.go))
- [Structure-to-Table Synchronizers](https://awesome-repositories.com/f/data-databases/table-definitions/object-mappings/table-to-code-mappers/structure-to-table-synchronizers.md) — Synchronizes Go application structures with database tables to ensure consistency between code and storage. ([source](https://github.com/go-xorm/xorm#readme))
- [Reflection-Based Mappings](https://awesome-repositories.com/f/data-databases/type-mapping-frameworks/script-to-native-type-mappings/entity-mappings/reflection-based-mappings.md) — Uses runtime reflection to map relational database rows to native Go structure fields.
- [Cursor-Based Iteration](https://awesome-repositories.com/f/data-databases/cursor-based-iteration.md) — Traverses database records using a cursor to map rows into objects efficiently. ([source](https://github.com/go-xorm/xorm/blob/master/rows.go))
- [Incremental Numeric Updates](https://awesome-repositories.com/f/data-databases/data-modification-apis/incremental-syncing/incremental-score-updaters/incremental-numeric-updates.md) — Enables atomic increments and decrements of numeric columns directly in the database. ([source](https://github.com/go-xorm/xorm/blob/master/session_cols.go))
- [Database Connection Managers](https://awesome-repositories.com/f/data-databases/database-connection-managers.md) — Provides utilities for managing persistent database connections and their lifecycles through sessions. ([source](https://github.com/go-xorm/xorm/blob/master/session_test.go))
- [Database Lifecycle Hooks](https://awesome-repositories.com/f/data-databases/database-lifecycle-hooks.md) — Triggers custom logic before or after database record operations using registered closures. ([source](https://github.com/go-xorm/xorm/blob/master/session.go))
- [Atomic Transactions](https://awesome-repositories.com/f/data-databases/database-management-systems/database-systems-management/connection-transaction-management/atomic-transactions.md) — Groups multiple database operations into a single atomic unit to ensure data consistency. ([source](https://github.com/go-xorm/xorm#readme))
- [Connection Pool Managers](https://awesome-repositories.com/f/data-databases/database-management-systems/database-systems-management/connection-transaction-management/connection-pool-managers.md) — Manages database connection lifecycles and pool settings wrapped within operational sessions.
- [Database Performance Optimizers](https://awesome-repositories.com/f/data-databases/database-performance-optimizers.md) — Provides performance optimizations including read-write splitting, query caching, and result streaming.
- [Record Counting](https://awesome-repositories.com/f/data-databases/database-record-management/record-counting.md) — Implements utilities to calculate the total number of database records matching specific search criteria. ([source](https://github.com/go-xorm/xorm/blob/master/session_stats_test.go))
- [Concurrency Versioning](https://awesome-repositories.com/f/data-databases/database-versioning/record-state-versioning/concurrency-versioning.md) — Prevents conflicting modifications by automatically incrementing a version field during updates. ([source](https://github.com/go-xorm/xorm/blob/master/tag_version_test.go))
- [Indexes and Constraints](https://awesome-repositories.com/f/data-databases/indexes-and-constraints.md) — Includes utilities to create and drop unique constraints and indexes for query performance optimization. ([source](https://github.com/go-xorm/xorm/blob/master/interface.go))
- [Read-Write Splitting](https://awesome-repositories.com/f/data-databases/multi-master-replication/read-write-splitting.md) — Routes modification requests to a primary database and read requests to replicas.
- [Optimistic Locking](https://awesome-repositories.com/f/data-databases/optimistic-locking.md) — Prevents concurrent update conflicts by tracking version counts on model instances. ([source](https://github.com/go-xorm/xorm#readme))
- [Result Streaming](https://awesome-repositories.com/f/data-databases/query-result-fetching/result-streaming.md) — Retrieves database rows incrementally via cursors to handle large datasets without memory exhaustion. ([source](https://github.com/go-xorm/xorm/blob/master/doc.go))
- [Hybrid Object-SQL Execution](https://awesome-repositories.com/f/data-databases/raw-sql-execution/hybrid-object-sql-execution.md) — Combines high-level object mapping operations with raw SQL statements within a single execution flow. ([source](https://github.com/go-xorm/xorm/blob/master/README_CN.md))
- [Record Deletion](https://awesome-repositories.com/f/data-databases/record-deletion.md) — Provides utilities for removing records based on primary keys or filter conditions. ([source](https://github.com/go-xorm/xorm/blob/master/session_delete_test.go))
- [Record Insertion](https://awesome-repositories.com/f/data-databases/record-insertion.md) — Provides standard interfaces for adding new data records to database tables. ([source](https://github.com/go-xorm/xorm/blob/master/session_cond_test.go))
- [Record Updating](https://awesome-repositories.com/f/data-databases/record-updating.md) — Provides methods for modifying existing data rows by mapping object fields to columns. ([source](https://github.com/go-xorm/xorm/blob/master/session_update.go))
- [Relation Loading Strategies](https://awesome-repositories.com/f/data-databases/relation-loading-strategies.md) — Retrieves associated records from linked tables in a single operation through cascade loading. ([source](https://github.com/go-xorm/xorm/blob/master/README.md))
- [Replica Load Balancers](https://awesome-repositories.com/f/data-databases/replica-load-balancers.md) — Includes a manager that distributes read traffic across a pool of database replicas.
- [Schema Management](https://awesome-repositories.com/f/data-databases/schema-management.md) — Provides capabilities to programmatically create, drop, and verify the existence of tables and indexes. ([source](https://github.com/go-xorm/xorm/blob/master/session_schema.go))
- [Single Record Retrievers](https://awesome-repositories.com/f/data-databases/single-record-retrievers.md) — Offers optimized methods for fetching a single record based on provided object fields. ([source](https://github.com/go-xorm/xorm/blob/master/session_get.go))
- [Soft Deletion Mechanisms](https://awesome-repositories.com/f/data-databases/soft-deletion-mechanisms.md) — Implements soft deletion by marking records with a timestamp instead of physical removal. ([source](https://github.com/go-xorm/xorm/blob/master/session_delete_test.go))
- [Table Creations](https://awesome-repositories.com/f/data-databases/storage-configuration/table-level-storage-formats/table-storage-option-modifications/table-creations.md) — Generates database table structures based on provided data models and specified storage engines. ([source](https://github.com/go-xorm/xorm/blob/master/session_schema_test.go))
- [Table Data Retrieval](https://awesome-repositories.com/f/data-databases/table-data-retrieval.md) — Provides mechanisms for retrieving multiple records from a table into slices or maps. ([source](https://github.com/go-xorm/xorm/blob/master/session_find.go))

### Software Engineering & Architecture

- [Struct Tags](https://awesome-repositories.com/f/software-engineering-architecture/metadata-attachments/struct-tags.md) — Maps Go structs to database tables using configuration tags embedded in struct definitions.
- [Database Record Hooks](https://awesome-repositories.com/f/software-engineering-architecture/reactive-update-scheduling/post-update-callbacks/lifecycle-update-hooks/database-record-hooks.md) — Provides interceptors that trigger custom logic automatically before and after database record operations.
- [Database Query Cancellation](https://awesome-repositories.com/f/software-engineering-architecture/rpc-cancellation/asynchronous-operation-cancellation/context-aware-cancellation/database-query-cancellation.md) — Implements database request cancellation and timeout management using Go contexts. ([source](https://github.com/go-xorm/xorm/blob/master/session_context_test.go))
- [Database Query Cancellations](https://awesome-repositories.com/f/software-engineering-architecture/rpc-cancellation/asynchronous-operation-cancellation/context-aware-cancellation/database-query-cancellations.md) — Controls database request lifecycles using contexts to implement timeouts and query cancellation. ([source](https://github.com/go-xorm/xorm/blob/master/engine_context_test.go))

### Programming Languages & Runtimes

- [Column Expression Updates](https://awesome-repositories.com/f/programming-languages-runtimes/expression-evaluators/dynamic-sql-expressions/column-expression-updates.md) — Allows assigning values to columns using SQL expressions or subqueries during updates. ([source](https://github.com/go-xorm/xorm/blob/master/session_cols_test.go))
- [Partial Column Updates](https://awesome-repositories.com/f/programming-languages-runtimes/expression-evaluators/dynamic-sql-expressions/partial-column-updates.md) — Supports updating only designated columns to prevent accidental overwriting of other fields. ([source](https://github.com/go-xorm/xorm/blob/master/session_cols_test.go))

### Part of an Awesome List

- [Database Drivers and ORMs](https://awesome-repositories.com/f/awesome-lists/data/database-drivers-and-orms.md) — Simple and powerful ORM for database operations.
- [Database Tools](https://awesome-repositories.com/f/awesome-lists/data/database-tools.md) — Versatile ORM supporting multiple relational database systems.
- [ORM and Data Mapping](https://awesome-repositories.com/f/awesome-lists/data/orm-and-data-mapping.md) — Simple and powerful ORM.
