mirror of
https://gitea.invidious.io/iv-org/shard-crystal-db.git
synced 2024-08-15 00:53:32 +00:00
1 line
226 KiB
JavaScript
1 line
226 KiB
JavaScript
|
crystal_doc_search_index_callback({"repository_name":"github.com/crystal-lang/crystal-db","body":"[![Build Status](https://travis-ci.org/crystal-lang/crystal-db.svg?branch=master)](https://travis-ci.org/crystal-lang/crystal-db)\n\n# crystal-db\n\nCommon db api for crystal. You will need to have a specific driver to access a database.\n\n* [sqlite](https://github.com/crystal-lang/crystal-sqlite3)\n* [mysql](https://github.com/crystal-lang/crystal-mysql)\n* [postgres](https://github.com/will/crystal-pg)\n\n## Installation\n\nAdd this to your application's `shard.yml`:\n\n```yaml\ndependencies:\n db:\n github: crystal-lang/crystal-db\n```\n\n## Documentation\n\n* [Latest API](http://crystal-lang.github.io/crystal-db/api/latest/)\n* [Crystal book](https://crystal-lang.org/docs/database/)\n\n## Usage\n\nSince this is an abstract db api, it's usage is through a concrete database driver.\n\n```crystal\nrequire \"db\"\nrequire \"sqlite3\"\n\nDB.open \"sqlite3:./file.db\" do |db|\n # When using the pg driver, use $1, $2, etc. instead of ?\n db.exec \"create table contacts (name text, age integer)\"\n db.exec \"insert into contacts values (?, ?)\", \"John Doe\", 30\n\n args = [] of DB::Any\n args << \"Sarah\"\n args << 33\n db.exec \"insert into contacts values (?, ?)\", args\n\n puts \"max age:\"\n puts db.scalar \"select max(age) from contacts\" # => 33\n\n puts \"contacts:\"\n db.query \"select name, age from contacts order by age desc\" do |rs|\n puts \"#{rs.column_name(0)} (#{rs.column_name(1)})\"\n # => name (age)\n rs.each do\n puts \"#{rs.read(String)} (#{rs.read(Int32)})\"\n # => Sarah (33)\n # => John Doe (30)\n end\n end\nend\n```\n\n## Roadmap\n\nIssues not yet addressed\n\n- [x] Support non prepared statements. [#25](https://github.com/crystal-lang/crystal-db/pull/25)\n- [x] Time data type. (implementation details depends on actual drivers)\n- [x] Data type extensibility. Allow each driver to extend the data types allowed.\n- [x] Transactions & nested transactions. [#27](https://github.com/crystal-lang/crystal-db/pull/27)\n- [x] Connection pool.\n- [ ] Direct access to `IO` to avoid memory allocation for blobs.\n\n## Contributing\n\n1. Fork it ( https://github.com/crystal-lang/crystal-db/fork )\n2. Create your feature branch (git checkout -b my-new-feature)\n3. Commit your changes (git commit -am 'Add some feature')\n4. Push to the branch (git push origin my-new-feature)\n5. Create a new Pull Request\n\n## Contributors\n\n- [bcardiff](https://github.com/bcardiff) Brian J. Cardiff - creator, maintainer\n","program":{"html_id":"github.com/crystal-lang/crystal-db/toplevel","path":"toplevel.html","kind":"module","full_name":"Top Level Namespace","name":"Top Level Namespace","abstract":false,"superclass":null,"ancestors":[{"html_id":"github.com/crystal-lang/crystal-db/Spec/Methods","kind":"module","full_name":"Spec::Methods","name":"Methods"},{"html_id":"github.com/crystal-lang/crystal-db/Spec/Expectations","kind":"module","full_name":"Spec::Expectations","name":"Expectations"}],"locations":[],"repository_name":"github.com/crystal-lang/crystal-db","program":true,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[{"html_id":"github.com/crystal-lang/crystal-db/Spec/Expectations","kind":"module","full_name":"Spec::Expectations","name":"Expectations"},{"html_id":"github.com/crystal-lang/crystal-db/Spec/Methods","kind":"module","full_name":"Spec::Methods","name":"Methods"}],"extended_modules":[{"html_id":"github.com/crystal-lang/crystal-db/Spec/Expectations","kind":"module","full_name":"Spec::Expectations","name":"Expectations"},{"html_id":"github.com/crystal-lang/crystal-db/Spec/Methods","kind":"module","full_name":"Spec::Methods","name":"Methods"}],"subclasses":[],"including_types":[],"namespace":null,"doc":null,"summary":null,"class_methods":[],"constructors":[],"instance_methods":[],"macros":[],"types":[{"html_id":"github.com/crystal-lang/crystal-db/DB","path":"DB.html","kind":"module","full_name":"DB","name":"DB","abstract":false,"superclass"
|