awesome-repositories.com
Blog
awesome-repositories.com

Descoperă cele mai bune repository-uri open source cu căutare AI.

ExploreazăCăutări recomandateAlternative open-sourceSoftware self-hostedBlogHartă site
ProiectDespreCum realizăm clasamentulPresăServer MCP
LegalConfidențialitateTermeni
© 2026 Bringes Technology SRL·VAT RO45896025·hello@awesome-repositories.com
·
go-pg avatar

go-pg/pg

0
View on GitHub↗
5,785 stele·413 fork-uri·Go·BSD-2-Clause·5 vizualizăripg.uptrace.dev↗

Pg

pg is a PostgreSQL object-relational mapper (ORM) for Go that maps Go structs to database tables and provides a fluent query builder for constructing SQL statements programmatically. At its core, it automatically generates CREATE TABLE statements from Go struct definitions using struct tags and naming conventions, and builds queries through method chaining with placeholder-based parameter binding to prevent SQL injection.

The library distinguishes itself through relation-aware join generation that automatically constructs JOIN clauses for has-one, has-many, many-to-many, and polymorphic associations defined in struct tags, along with a hook-driven model lifecycle that executes user-defined callbacks before and after select, insert, update, and delete operations. It supports batch operations that combine multiple row insertions, updates, or deletions into single SQL statements to reduce round trips, and provides streaming row iteration that processes query results row by row via a callback function without loading the entire result set into memory. Schema migration capabilities include advisory locking for zero-downtime deployments, and the connection pool features automatic retry with circuit breaker protection against cascading errors.

The library covers the full range of database operations including transactions, prepared statements, bulk data handling via COPY commands, and support for PostgreSQL-specific features such as arrays, UUID generation, table partitioning, and soft deletes. It also provides real-time notification handling through LISTEN and NOTIFY channels, query tracing for performance monitoring, and the ability to work with raw SQL alongside the ORM layer.

Features

  • SQL ORMs - Maps Go structs to PostgreSQL tables and builds SQL queries via a fluent ORM API.
  • Go Struct-to-Table Generators - Defines a Go struct whose exported fields automatically map to columns in a PostgreSQL table.
  • Go PostgreSQL ORMs - Maps Go structs to PostgreSQL tables and provides a fluent query builder with relation-aware joins and batch operations.
  • Batch Data Operations - Performs bulk inserts, updates, and deletes in a single database round trip.
  • Batch Insert, Update, or Delete Operations - Combines multiple row insertions, updates, or deletions into single SQL statements to reduce round trips.
  • Atomic Transaction Execution - Groups multiple database operations into atomic units that commit or roll back as a whole.
  • Connection Establishment Utilities - Establishes connections to PostgreSQL databases using connection strings or structured options with health verification.
  • Fluent Query Builders - Constructs SQL statements by chaining method calls on a model object for programmatic query composition.
  • Select Query Builders - Constructs SELECT statements with columns, joins, conditions, grouping, ordering, limits, and offsets using a fluent API.
  • Struct-Driven Schema Generators - Generates tables from Go struct definitions and supports schema creation options for rapid prototyping and testing.
  • Batch Row Operations - Combines multiple row insertions, updates, or deletions into single SQL statements to minimize database network calls.
  • Database Transaction Management - Wraps multiple database operations in a transaction that commits or rolls back as a single atomic unit.
  • Primary Key Retrievals - Retrieves single database rows by primary key value, populating Go structs.
  • Fluent Query Construction - Chain methods on a model object to construct readable and composable SQL statements for database operations.
  • Fluent Query Builders - Constructs SQL statements programmatically in Go using method chaining with placeholder-based parameter binding.
  • Bulk ORM Operations - Performs batch inserts, updates, and deletes on multiple rows in a single database round trip.
  • Many-to-Many Associations - Maps many-to-many associations through intermediary join tables with automatic JOIN generation.
  • Relation Declarations via Struct Tags - Declares has-one, belongs-to, has-many, and many-to-many relationships between Go structs.
  • Relationship Definitions - Defines and queries has-one, belongs-to, has-many, and many-to-many associations between structs.
  • SQL Placeholder Bindings - Substitutes question mark placeholders with safely escaped parameters to prevent SQL injection.
  • Record Deletion - Removes rows by primary key, condition, or a list of IDs using a fluent API.
  • Record Insertion - Inserts a struct into the database and returns generated primary keys or all columns.
  • Multi-Record Insertions - Inserts a slice of structs or multiple arguments in a single INSERT statement.
  • Record Updating - Updates columns of a single struct by primary key or custom condition, optionally returning values.
  • Eager-Loaded Relation Queries - Fetches associated records in the same query using a relation definition on the model.
  • Eager-Loading Joins - Eager-loads associated models using LEFT JOINs with configurable column selection.
  • ORM Join Generators - Automatically constructs JOIN clauses for has-one, has-many, many-to-many, and polymorphic associations defined in struct tags.
  • Relation Definitions via Struct Tags - Marks fields as has-one, has-many, many-to-many, or polymorphic relations so queries can automatically join related data.
  • Relationship Configuration via Struct Tags - Configures has-one, belongs-to, has-many, and many-to-many associations between struct models.
  • SQL Query Builders - Builds SQL queries programmatically in Go using a fluent API with placeholders, joins, subqueries, and raw SQL injection.
  • Struct-to-Table Mappings - Maps Go struct fields to PostgreSQL columns, handling basic types, JSON, arrays, hstore, and composite types.
  • Database Connection Pools - Manages reusable database connections with automatic retry and circuit breaker protection against cascading errors.
  • SQL Named Placeholder References - Provides named and positional placeholder binding for SQL query parameters in Go structs.
  • SQL Batching - Combines multiple row insertions, updates, or deletions into single SQL statements to reduce round trips.
  • Transactional Wrappers - Wraps database operations in atomic transactions with automatic commit or rollback.
  • Model Lifecycle Hooks - Executes user-defined callbacks before and after select, insert, update, and delete operations on struct models.
  • Prepared Statement Executors - Groups multiple queries into atomic transactions and reuses compiled query plans for repeated execution.
  • PostgreSQL Array Operations - Encodes Go slices into PostgreSQL array literals for array operators like contains.
  • Common Table Expressions - Provides a WITH clause builder for wrapping subqueries as reusable CTEs.
  • Zero-Value Field Skipping - Updates only non-zero struct fields, skipping zero values to avoid overwriting with NULL.
  • Database Migration Management - Applies schema changes safely with advisory locking for zero-downtime migrations.
  • Bulk - Updates several structs in a single query using a VALUES list matched by primary key.
  • Zero-Downtime Schema Migrations - Applies schema changes with advisory locking for zero-downtime deployments.
  • Advisory Locking Mechanisms - Applies database schema changes in a safe order using advisory locks to prevent downtime during concurrent migrations.
  • Nullable Column Mappings - Maps nullable columns using Go pointers or sql.Null types to distinguish NULL from zero values.
  • Prepared Statements - Compiles and caches SQL statements for repeated execution with different parameters.
  • Raw SQL Execution - Inserts unquoted SQL expressions directly into queries for dynamic or complex clauses.
  • Select-or-Insert Operations - Attempts to select an existing row by condition and inserts a new one if none is found.
  • Upsert Operations - Inserts a row or updates it on conflict using PostgreSQL's ON CONFLICT DO UPDATE clause.
  • Row-Based Result Streaming - Processes query results row by row via a callback function without loading the entire result set into memory.
  • PostgreSQL Schema Migrations - Applies database schema changes safely with advisory locking for zero-downtime migrations and supports table partitioning and soft deletes.
  • Soft Deletion - Marks rows as deleted by setting a timestamp field instead of physical removal.
  • Table Partitioning Configurations - Adds partition-by clauses for table creation and marks a timestamp field to enable soft-delete behavior.
  • Struct Tag Overrides - Overrides default table names, column names, SQL types, constraints, and relations using struct tags to match an existing schema.
  • Subquery Execution - Places subqueries inside FROM, WHERE, or other clauses to compose complex queries.
  • Table Joining Operations - Adds JOIN clauses with custom conditions to SELECT queries.
  • IN Clause Builders - Expands slices or composite key pairs into properly formatted IN lists for multiple-value matching.
  • Table Partitioning by Column - Creates parent tables with PARTITION BY clauses using struct tags.
  • Bulk Data Transfers via COPY - Transfers large datasets between Go and PostgreSQL using COPY FROM and COPY TO commands for high-throughput operations.
  • Map-Based Database Updates - Updates rows in a table using a map of column names to values.
  • Partial Column Updates - Ships a fluent API for updating only the named columns of a struct or map.
  • Query Retries - Automatically re-executes queries on transient network errors for resilience.
  • UUID Field Mappings - Maps Go's uuid.UUID type to PostgreSQL UUID columns for automatic serialization.
  • Object Relational Mappers - ORM focused on PostgreSQL features and performance.
  • Object Relational Mapping - PostgreSQL-focused ORM.
  • ORM and Data Mapping - PostgreSQL-focused ORM with high performance.
  • Database Drivers - Go database driver.

Istoric stele

Graficul istoricului de stele pentru go-pg/pgGraficul istoricului de stele pentru go-pg/pg

Căutare AI

Explorează mai multe repository-uri excelente

Descrie ce ai nevoie în limbaj simplu — AI-ul sortează mii de proiecte open source selectate în funcție de relevanță.

Start searching with AI

Întrebări frecvente

Ce face go-pg/pg?

pg is a PostgreSQL object-relational mapper (ORM) for Go that maps Go structs to database tables and provides a fluent query builder for constructing SQL statements programmatically. At its core, it automatically generates CREATE TABLE statements from Go struct definitions using struct tags and naming conventions, and builds queries through method chaining with placeholder-based parameter binding to prevent SQL injection.

Care sunt principalele funcționalități ale go-pg/pg?

Principalele funcționalități ale go-pg/pg sunt: SQL ORMs, Go Struct-to-Table Generators, Go PostgreSQL ORMs, Batch Data Operations, Batch Insert, Update, or Delete Operations, Atomic Transaction Execution, Connection Establishment Utilities, Fluent Query Builders.

Care sunt câteva alternative open-source pentru go-pg/pg?

Alternativele open-source pentru go-pg/pg includ: uptrace/bun — Bun is a type-safe object relational mapper for Go that prioritizes SQL-first query construction and result mapping.… codeigniter4/codeigniter4 — CodeIgniter is a PHP web framework built on the Model-View-Controller pattern, designed for building full-stack web… catfan/medoo — Medoo is a lightweight PHP database abstraction layer and SQL query builder. It serves as a minimal database wrapper… dotnetcore/freesql — FreeSql is a .NET object-relational mapper and data access layer that translates object-oriented code into SQL for… tortoise/tortoise-orm — Tortoise ORM is an asynchronous object-relational mapper for Python that mirrors Django's model and queryset API while… go-xorm/xorm — xorm is a relational mapper and object-relational mapping tool for Go. It translates Go structures into SQL queries…

Alternative open-source pentru Pg

Proiecte open-source similare, clasificate după numărul de funcționalități comune cu Pg.
  • uptrace/bunAvatar uptrace

    uptrace/bun

    4,867Vezi pe GitHub↗

    Bun is a type-safe object relational mapper for Go that prioritizes SQL-first query construction and result mapping. It functions as a programmable SQL query builder, a database connection manager, and a tool for mapping database tables to Go structs. The project distinguishes itself through a multi-dialect SQL support system, allowing a single codebase to interact with different database engines via a consistent interface. It includes a built-in database observability tool for query interception, distributed tracing, and logging, as well as a schema migration tool for versioning structural c

    Godatabasegogolang
    Vezi pe GitHub↗4,867
  • codeigniter4/codeigniter4Avatar codeigniter4

    codeigniter4/CodeIgniter4

    5,924Vezi pe GitHub↗

    CodeIgniter is a PHP web framework built on the Model-View-Controller pattern, designed for building full-stack web applications. It provides a lightweight toolkit with minimal configuration, organizing application logic into controllers, models, and views for clean separation of concerns. The framework includes a fluent query builder for constructing SQL statements programmatically, PSR-4 autoloading with namespace mapping, and a service-based dependency injection container for managing shared class instances. The framework distinguishes itself through its comprehensive set of built-in tools

    PHPcodeignitercodeigniter4framework-php
    Vezi pe GitHub↗5,924
  • catfan/medooAvatar catfan

    catfan/Medoo

    4,943Vezi pe GitHub↗

    Medoo is a lightweight PHP database abstraction layer and SQL query builder. It serves as a minimal database wrapper that provides a unified API to execute queries across multiple SQL engines, translating PHP method calls into specific database dialects. The project enables multi-dialect SQL interfacing, allowing a single codebase to interact with various backends including MySQL, MariaDB, PostgreSQL, SQLite, MSSQL, Oracle, and Sybase. It uses prepared statement parameterization to prevent injection attacks while maintaining a programmatic approach to constructing complex SQL statements. The

    PHPcomposerdatabasehacktoberfest
    Vezi pe GitHub↗4,943
  • dotnetcore/freesqlAvatar dotnetcore

    dotnetcore/FreeSql

    4,388Vezi pe GitHub↗

    FreeSql is a .NET object-relational mapper and data access layer that translates object-oriented code into SQL for multiple relational database providers. It functions as a fluent SQL query builder and database schema synchronizer, allowing developers to align database table and index structures with entity class definitions. The framework is specifically optimized for .NET Native AOT to ensure reduced memory footprints and faster startup times. It includes a database traffic manager to distribute load through read-write splitting, dynamic table sharding, and tenant-based data isolation. Bro

    C#accessclickhousecodefirst
    Vezi pe GitHub↗4,388
  • Vezi toate cele 30 alternative pentru Pg→