Gatsby

Gatsby Database Toolkit For Go (ORM, SQL Builder and SQLUtils)
Alternatives To Gatsby
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Knex17,59718,0962,788a day ago248August 31, 2022830mitJavaScript
A query builder for PostgreSQL, MySQL, CockroachDB, SQL Server, SQLite3 and Oracle, designed to be flexible, portable, and fun to use.
Objection.js7,0057073384 days ago195December 30, 2021106mitJavaScript
An SQL-friendly ORM for Node.js
Querybuilder2,6618992 months ago56September 19, 2022119mitC#
SQL query builder, written in c#, helps you build complex queries easily, supports SqlServer, MySql, PostgreSql, Oracle, Sqlite and Firebird
Pypika2,0001945a month ago213March 15, 2022167apache-2.0Python
PyPika is a python SQL query builder that exposes the full richness of the SQL language using a syntax that reflects the resulting query. PyPika excels at all sorts of SQL queries but is especially useful for data analysis.
Goqu1,846463 months ago25October 16, 2021104mitGo
SQL builder and query library for golang
React Awesome Query Builder1,5445820 days ago144March 15, 2022116mitJavaScript
User-friendly query builder for React
Squel1,5204231543 years ago79June 18, 2019121mitCoffeeScript
:office: SQL query string builder for Javascript
Gendry1,48518a month ago16March 23, 202118apache-2.0Go
a golang library for sql builder
Jet1,272211 days ago29May 17, 202221apache-2.0Go
Type safe SQL builder with code generation and automatic query result data mapping
Go Sqlbuilder99433015 days ago27June 25, 20228mitGo
A flexible and powerful SQL string builder library plus a zero-config ORM.
Alternatives To Gatsby
Select To Compare


Alternative Project Comparisons
Readme

Gatsby Database Toolkit For Go

Query Builder

Gatsby Query provides a general query object to build SQL for selecting, updating, deleting, inserting records.

Currently it supports 4 mode (CRUD) to build SQL.

To Build Select Query:

import "gatsby"

staffs := gatsby.NewQuery("staffs")
staffs.Select("id", "name")
staffs.WhereFromMap( gatsby.ArgMap{
    "name": "John"
})
sql := staffs.String()
args := staffs.Args()

To Build Insert Query:

import "gatsby"
query := gatsby.NewQuery("staffs")
query.Insert(map[string]interface{} {
    "name": "John",
})
sql := query.String()

To Build Update Query:

query := gatsby.NewQuery("staffs")
query.Update(map[string]interface{} {
    "name": "John",
})
query.WhereFromMap(map[string]interface{} {
    "id": 3,
})
sql := query.String()

SQLFragments

More flexible SQL Builder by fragments.

You can append query fragments then combine them into one SQL string by joining, and you can use the generated SQL in anywhere you want to combine with your own SQL statements.

SQLFragments filters these question marks into placeholders with number format, for example, the first ? will be $1 and the second ? will be $2.

import "gatsby"
frag := gatsby.NewFragment()
frag.AppendQuery("name = ?", "John")
frag.AppendQuery("phone = ?", "John")
sql := frag.Join("OR")         // generates name = $1 AND phone = $2
args := frag.Args()

BaseRecord

The BaseRecord provides a general CRUD operations on a struct type.

To define your model with Gatsby BaseRecord:

package app
import "github.com/c9s/gatsby"

type Staff struct {
	Id        int64     `json:"id" field:"id,primary,serial"`
	Name      string    `json:"name"`
	Gender    string    `json:"gender"`
	Phone     string    `json:"phone"`
	CellPhone string    `json:"cell_phone"`
	gatsby.BaseRecord
}

Then you can do CRUD operations on the struct object:

import "github.com/c9s/gatsby"
import _ "github.com/mattn/go-sqlite3"
import "database/sql"

db, err := sql.Open("sqlite3", "./foo.db")
gatsby.SetupConnection(db, gatsby.DriverSqlite)

staff := gatsby.NewRecord(&Staff{}).(*Staff)

res := staff.Load(10)   // load the record where primary key = 10

if res.Error != nil {
    // handle error here
}
if res.IsEmpty { 
    // handle empty record here
}

staff.Name = "John"

res := staff.Update()

res := staff.Delete()   // delete the record where primary key = 10

res := staff.Create()    // create another record
if res.Error != nil {

}
Popular Builder Projects
Popular Sql Projects
Popular Build Tools Categories

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Go
Sql
Builder
Gatsby
Struct
Fragments
Sql Builder