Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Cockroach | 27,855 | 50 | 24 | 5 hours ago | 249 | August 06, 2021 | 5,824 | other | Go | |
CockroachDB - the open source, cloud-native distributed SQL database. | ||||||||||
Mongo | 24,443 | 1 | 5 hours ago | 22 | October 09, 2022 | 80 | other | C++ | ||
The MongoDB Database | ||||||||||
Mysql | 13,691 | 4,892 | 11,214 | 9 hours ago | 51 | April 25, 2023 | 74 | mpl-2.0 | Go | |
Go MySQL Driver is a MySQL driver for Go's (golang) database/sql package | ||||||||||
Migrate | 12,273 | 815 | 6 days ago | 132 | June 11, 2023 | 294 | other | Go | ||
Database migrations. CLI and Golang library. | ||||||||||
Node Mongodb Native | 9,848 | 116,995 | 11,023 | a day ago | 426 | July 06, 2023 | 20 | apache-2.0 | TypeScript | |
The Official MongoDB Node.js Driver | ||||||||||
Yugabyte Db | 8,091 | 5 hours ago | 5,361 | other | C | |||||
YugabyteDB - the cloud native distributed SQL database for mission-critical applications. | ||||||||||
Mongo Go Driver | 7,641 | 6,060 | 5 hours ago | 330 | August 02, 2023 | 10 | apache-2.0 | Go | ||
The Official Golang driver for MongoDB | ||||||||||
Go Sqlmock | 5,425 | 1,336 | a month ago | 21 | June 28, 2020 | 75 | other | Go | ||
Sql mock driver for golang to test database interactions | ||||||||||
Postgres | 4,966 | 3 | 165 | 6 days ago | 38 | May 31, 2023 | 50 | unlicense | JavaScript | |
Postgres.js - The Fastest full featured PostgreSQL client for Node.js and Deno | ||||||||||
Psycopg2 | 3,034 | 6,031 | 1,893 | 8 hours ago | 21 | August 05, 2023 | 18 | other | C | |
PostgreSQL database adapter for the Python programming language |
Common db api for crystal. You will need to have a specific driver to access a database.
If you are creating a shard that will work with any driver, then add crystal-db
as a dependency in shard.yml
:
dependencies:
db:
github: crystal-lang/crystal-db
If you are creating an application that will work with some specific driver(s), then add them in shard.yml
:
dependencies:
sqlite3:
github: crystal-lang/crystal-sqlite3
crystal-db
itself will be a nested dependency if drivers are included.
Note: Multiple drivers can be included in the same application.
This shard only provides an abstract database API. In order to use it, a specific driver for the intended database has to be required as well:
The following example uses SQLite where ?
indicates the arguments. If PostgreSQL is used $1
, $2
, etc. should be used. crystal-db
does not interpret the statements.
require "db"
require "sqlite3"
DB.open "sqlite3:./file.db" do |db|
# When using the pg driver, use $1, $2, etc. instead of ?
db.exec "create table contacts (name text, age integer)"
db.exec "insert into contacts values (?, ?)", "John Doe", 30
args = [] of DB::Any
args << "Sarah"
args << 33
db.exec "insert into contacts values (?, ?)", args: args
puts "max age:"
puts db.scalar "select max(age) from contacts" # => 33
puts "contacts:"
db.query "select name, age from contacts order by age desc" do |rs|
puts "#{rs.column_name(0)} (#{rs.column_name(1)})"
# => name (age)
rs.each do
puts "#{rs.read(String)} (#{rs.read(Int32)})"
# => Sarah (33)
# => John Doe (30)
end
end
end
Issues not yet addressed:
IO
to avoid memory allocation for blobs.