All Projects → crystal-lang → Crystal Db

crystal-lang / Crystal Db

Licence: mit
Common db api for crystal

Programming Languages

crystal
512 projects

Labels

Projects that are alternatives of or similar to Crystal Db

Ldb
A C++ REPL / CLI for LevelDB
Stars: ✭ 201 (-5.63%)
Mutual labels:  database
Technicalnote
Repository to store what we have studied. 📖 We want everyone to get a job through TechnicalNote.
Stars: ✭ 206 (-3.29%)
Mutual labels:  database
Json Flatfile Datastore
Simple JSON flat file data store with support for typed and dynamic data.
Stars: ✭ 212 (-0.47%)
Mutual labels:  database
Rustorm
an orm for rust
Stars: ✭ 205 (-3.76%)
Mutual labels:  database
Iowow
The skiplist based persistent key/value storage engine
Stars: ✭ 206 (-3.29%)
Mutual labels:  database
Tracker Enabled Dbcontext
Tracker-enabled DbContext offers you to implement full auditing in your database
Stars: ✭ 210 (-1.41%)
Mutual labels:  database
Pymilvus
Python SDK for Milvus.
Stars: ✭ 199 (-6.57%)
Mutual labels:  database
Dbtester
Distributed database benchmark tester
Stars: ✭ 214 (+0.47%)
Mutual labels:  database
Vuerd
ERD Editor
Stars: ✭ 208 (-2.35%)
Mutual labels:  database
Bow
Bow - Minimal embedded database powered by Badger
Stars: ✭ 212 (-0.47%)
Mutual labels:  database
Migrate
Database migrations. CLI and Golang library.
Stars: ✭ 2,315 (+986.85%)
Mutual labels:  database
Postgres
🐘 Run PostgreSQL in Kubernetes
Stars: ✭ 205 (-3.76%)
Mutual labels:  database
3dcitydb
3D City Database - The Open Source CityGML Database
Stars: ✭ 210 (-1.41%)
Mutual labels:  database
Mongoke
Instant Graphql for MongoDb (active branch is golang, rewrite in process)
Stars: ✭ 203 (-4.69%)
Mutual labels:  database
Platform
Archived incubation repo for InfluxDB 2.0
Stars: ✭ 213 (+0%)
Mutual labels:  database
Barrel Platform
Distributed database for the modern world
Stars: ✭ 201 (-5.63%)
Mutual labels:  database
Endb
Key-value storage for multiple databases. Supports MongoDB, MySQL, Postgres, Redis, and SQLite.
Stars: ✭ 208 (-2.35%)
Mutual labels:  database
Java Persistence Frameworks Comparison
Comparison of non-JPA SQL mapping frameworks for Java (Jooq, Spring JDBCTemplate, MyBatis, EBean, JDBI, Speedment, sql2o)
Stars: ✭ 213 (+0%)
Mutual labels:  database
Omnidb
Web tool for database management
Stars: ✭ 2,709 (+1171.83%)
Mutual labels:  database
Anima
Minimal database operation library.
Stars: ✭ 210 (-1.41%)
Mutual labels:  database

Build Status

crystal-db

Common db api for crystal. You will need to have a specific driver to access a database.

Installation

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.

Documentation

Usage

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

Roadmap

Issues not yet addressed:

  • [x] Support non prepared statements. #25
  • [x] Time data type. (implementation details depends on actual drivers)
  • [x] Data type extensibility. Allow each driver to extend the data types allowed.
  • [x] Transactions & nested transactions. #27
  • [x] Connection pool.
  • [ ] Logging
  • [ ] Direct access to IO to avoid memory allocation for blobs.

Contributing

  1. Fork it ( https://github.com/crystal-lang/crystal-db/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

  • bcardiff Brian J. Cardiff - creator, maintainer
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].