qry alternatives and similar packages
Based on the "Database" category.
Alternatively, view qry alternatives based on common mentions on social networks and blogs.
-
Milvus
A cloud-native vector database, storage for next generation AI applications -
cockroach
CockroachDB - the open source, cloud-native distributed SQL database. -
tidb
TiDB is an open-source, cloud-native, distributed, MySQL-Compatible database for elastic scale and real-time analytics. Try AI-powered Chat2Query free at : https://tidbcloud.com/free-trial -
vitess
Vitess is a database clustering system for horizontal scaling of MySQL. -
TinyGo
Go compiler for small places. Microcontrollers, WebAssembly (WASM/WASI), and command-line tools. Based on LLVM. -
groupcache
groupcache is a caching and cache-filling library, intended as a replacement for memcached in many cases. -
VictoriaMetrics
VictoriaMetrics: fast, cost-effective monitoring solution and time series database -
immudb
immudb - immutable database based on zero trust, SQL and Key-Value, tamperproof, data change history -
go-cache
An in-memory key:value store/cache (similar to Memcached) library for Go, suitable for single-machine applications. -
buntdb
BuntDB is an embeddable, in-memory key/value database for Go with custom indexing and geospatial support -
pREST
PostgreSQL ➕ REST, low-code, simplify and accelerate development, ⚡ instant, realtime, high-performance on any Postgres application, existing or new -
rosedb
🚀 A high performance NoSQL database based on bitcask, supports string, list, hash, set, and sorted set. -
xo
Command line tool to generate idiomatic Go code for SQL databases supporting PostgreSQL, MySQL, SQLite, Oracle, and Microsoft SQL Server -
tiedot
A rudimentary implementation of a basic document (NoSQL) database in Go -
nutsdb
A simple, fast, embeddable, persistent key/value store written in pure Go. It supports fully serializable transactions and many data structures such as list, set, sorted set. -
cache2go
Concurrency-safe Go caching library with expiration capabilities and access counters -
GCache
An in-memory cache library for golang. It supports multiple eviction policies: LRU, LFU, ARC -
fastcache
Fast thread-safe inmemory cache for big number of entries in Go. Minimizes GC overhead -
gocraft/dbr (database records)
Additions to Go's database/sql for super fast performance and convenience. -
CovenantSQL
A decentralized, trusted, high performance, SQL database with blockchain features
Static code analysis for 29 languages.
Do you think we are missing an alternative of qry or a related project?
Popular Comparisons
README
About
qry is a general purpose library for storing your raw database queries in .sql files with all benefits of modern IDEs, instead of strings and constants in the code, and using them in an easy way inside your application with all the profit of compile time constants.
qry recursively loads all .sql files from a specified folder, parses them according to predefined rules and returns a reusable object, which is actually just a map[string]string
with some sugar. Multiple queries inside a single file are separated with standard SQL comment syntax: -- qry: QueryName
. A QueryName
must match [A-Za-z_]+
.
gen tool is used for automatic generation of constants for all user specified query_names
.
Installation
go get -u github.com/HnH/qry/cmd/qry-gen
Usage
Prepare sql files: queries/one.sql
:
-- qry: InsertUser
INSERT INTO `users` (`name`) VALUES (?);
-- qry: GetUserById
SELECT * FROM `users` WHERE `user_id` = ?;
And the second one queries/two.sql
:
-- qry: DeleteUsersByIds
DELETE FROM `users` WHERE `user_id` IN ({ids});
Generate constants: qry-gen -dir=./queries -pkg=/path/to/your/go/pkg
Will produce /path/to/your/go/pkg/qry.go
with:
package pkg
const (
// one.sql
InsertUser = "INSERT INTO `users` (`name`) VALUES (?);"
GetUserById = "SELECT * FROM `users` WHERE `user_id` = ?;"
// two.sql
DeleteUsersByIds = "DELETE FROM `users` WHERE `user_id` IN ({ids});"
)
As a best practice include this qry-gen call in your source code with go:generate prefix: //go:generate qry-gen -dir=./queries -pkg=/path/to/your/go/pkg
and just execute go generate
before each build.
Now it's time to use qry inside your project:
func main() {
/**
* The most obvious way is to use generated constants in the source code
*/
// INSERT INTO `users` (`name`) VALUES (?);
println(pkg.InsertUser)
// DELETE FROM `users` WHERE `user_id` IN (?,?,?);
println(qry.Query(pkg.DeleteUsersByIds).Replace("{ids}", qry.In(3)))
/**
* As an alternative you can manually parse .sql files in the directory and work with output
*/
if q, err := qry.Dir("/path/to/your/go/pkg/queries"); err != nil {
log.Fatal(err)
}
// SELECT * FROM `users` WHERE `user_id` = ?;
println(q["one.sql"]["GetUserById"])
// DELETE FROM `users` WHERE `user_id` IN (?,?,?);
println(q["two.sql"]["DeleteUsersByIds"].Replace("{ids}", qry.In(3)))
}