All Projects → slicebit → Qb

slicebit / Qb

Licence: lgpl-2.1
The database toolkit for go

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Qb

Db
Data access layer for PostgreSQL, CockroachDB, MySQL, SQLite and MongoDB with ORM-like features.
Stars: ✭ 2,832 (+440.46%)
Mutual labels:  sql, orm, database, mysql, postgresql, db
Electrocrud
Database CRUD Application Built on Electron | MySQL, Postgres, SQLite
Stars: ✭ 1,267 (+141.79%)
Mutual labels:  sql, database, mysql, postgresql, sqlite3
Eralchemy
Entity Relation Diagrams generation tool
Stars: ✭ 767 (+46.37%)
Mutual labels:  sql, sqlalchemy, database, mysql, postgresql
Sqlcheck
Automatically identify anti-patterns in SQL queries
Stars: ✭ 2,062 (+293.51%)
Mutual labels:  sql, database, mysql, postgresql, sqlite3
Go Sqlbuilder
A flexible and powerful SQL string builder library plus a zero-config ORM.
Stars: ✭ 539 (+2.86%)
Mutual labels:  sql, orm, database, mysql, postgresql
Rel
💎 Modern Database Access Layer for Golang - Testable, Extendable and Crafted Into a Clean and Elegant API
Stars: ✭ 317 (-39.5%)
Mutual labels:  sql, orm, database, mysql, postgresql
Walkable
A Clojure(script) SQL library for building APIs: Datomic® (GraphQL-ish) pull syntax, data driven configuration, dynamic filtering with relations in mind
Stars: ✭ 384 (-26.72%)
Mutual labels:  sql, orm, mysql, postgresql, sqlite3
Lucid
AdonisJS official SQL ORM. Supports PostgreSQL, MySQL, MSSQL, Redshift, SQLite and many more
Stars: ✭ 613 (+16.98%)
Mutual labels:  sql, orm, mysql, postgresql, sqlite3
Nut
Advanced, Powerful and easy to use ORM for Qt
Stars: ✭ 181 (-65.46%)
Mutual labels:  sql, orm, database, mysql, postgresql
Openrecord
Make ORMs great again!
Stars: ✭ 474 (-9.54%)
Mutual labels:  sql, orm, mysql, postgresql, sqlite3
Mikro Orm
TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, MariaDB, PostgreSQL and SQLite databases.
Stars: ✭ 3,874 (+639.31%)
Mutual labels:  orm, database, mysql, postgresql, sqlite3
Jooq
jOOQ is the best way to write SQL in Java
Stars: ✭ 4,695 (+795.99%)
Mutual labels:  sql, orm, database, mysql, postgresql
Sworm
a write-only ORM for Node.js
Stars: ✭ 128 (-75.57%)
Mutual labels:  sql, orm, mysql, postgresql, sqlite3
Linq2db
Linq to database provider.
Stars: ✭ 2,211 (+321.95%)
Mutual labels:  sql, orm, database, mysql, postgresql
Sqlboiler
Generate a Go ORM tailored to your database schema.
Stars: ✭ 4,497 (+758.21%)
Mutual labels:  orm, database, mysql, postgresql, sqlite3
Denodb
MySQL, SQLite, MariaDB, PostgreSQL and MongoDB ORM for Deno
Stars: ✭ 498 (-4.96%)
Mutual labels:  orm, database, mysql, postgresql, sqlite3
Sqlc
Generate type-safe code from SQL
Stars: ✭ 4,564 (+770.99%)
Mutual labels:  sql, orm, mysql, postgresql
Xo
Command line tool to generate idiomatic Go code for SQL databases supporting PostgreSQL, MySQL, SQLite, Oracle, and Microsoft SQL Server
Stars: ✭ 2,974 (+467.56%)
Mutual labels:  sql, orm, mysql, postgresql
Node Orm2
Object Relational Mapping
Stars: ✭ 3,063 (+484.54%)
Mutual labels:  orm, database, mysql, postgresql
Sqlfiddle3
New version based on vert.x and docker
Stars: ✭ 242 (-53.82%)
Mutual labels:  sql, database, mysql, postgresql

alt text

qb - the database toolkit for go

Build Status Coverage Status License (LGPL version 2.1) Go Report Card GoDoc

This project is currently pre 1.

Currently, it's not feature complete. It can have potential bugs. There are no tests covering concurrency race conditions. It can crash especially in concurrency. Before 1.x releases, each major release could break backwards compatibility.

About qb

qb is a database toolkit for easier db queries in go. It is inspired from python's best orm, namely sqlalchemy. qb is an orm(sqlx) as well as a query builder. It is quite modular in case of using just expression api and query building stuff.

Documentation

The documentation is hosted in readme.io which has great support for markdown docs. Currently, the docs are about 80% - 90% complete. The doc files will be added to this repo soon. Moreover, you can check the godoc from here. Contributions & Feedbacks in docs are welcome.

Features

  • Support for postgres(9.5.+), mysql & sqlite3
  • Powerful expression API for building queries & table ddls
  • Struct to table ddl mapper where initial table migrations can happen
  • Transactional session api that auto map structs to queries
  • Foreign key definitions
  • Single & Composite column indices
  • Relationships (soon.. probably in 0.3 milestone)

Installation

go get -u github.com/slicebit/qb

If you want to install test dependencies then;

go get -u -t github.com/slicebit/qb

Quick Start

package main

import (
	"fmt"
	"github.com/slicebit/qb"
	_ "github.com/mattn/go-sqlite3"
    _ "github.com/slicebit/qb/dialects/sqlite"
)

type User struct {
	ID       string `db:"id"`
	Email    string `db:"email"`
	FullName string `db:"full_name"`
	Oscars   int    `db:"oscars"`
}

func main() {

	users := qb.Table(
		"users",
		qb.Column("id", qb.Varchar().Size(40)),
		qb.Column("email", qb.Varchar()).NotNull().Unique(),
		qb.Column("full_name", qb.Varchar()).NotNull(),
		qb.Column("oscars", qb.Int()).NotNull().Default(0),
		qb.PrimaryKey("id"),
	)

	db, err := qb.New("sqlite3", "./qb_test.db")
	if err != nil {
		panic(err)
	}

	defer db.Close()

	metadata := qb.MetaData()

	// add table to metadata
	metadata.AddTable(users)

	// create all tables registered to metadata
	metadata.CreateAll(db)
	defer metadata.DropAll(db) // drops all tables

	ins := qb.Insert(users).Values(map[string]interface{}{
		"id":        "b6f8bfe3-a830-441a-a097-1777e6bfae95",
		"email":     "[email protected]",
		"full_name": "Jack Nicholson",
	})

	_, err = db.Exec(ins)
	if err != nil {
		panic(err)
	}

	// find user
	var user User

	sel := qb.Select(users.C("id"), users.C("email"), users.C("full_name")).
		From(users).
		Where(users.C("id").Eq("b6f8bfe3-a830-441a-a097-1777e6bfae95"))

	err = db.Get(sel, &user)
	fmt.Printf("%+v\n", user)
}

Credits

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].