Skip to content

Commit 8738b26

Browse files
committed
Driver/Crystal: Add dedicated page
1 parent 1d3251e commit 8738b26

File tree

3 files changed

+80
-0
lines changed

3 files changed

+80
-0
lines changed

docs/_assets/icon/crystal-logo.svg

Lines changed: 4 additions & 0 deletions
Loading

docs/connect/crystal.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
(connect-crystal)=
2+
3+
# Crystal
4+
5+
:::{div} sd-text-muted
6+
Connect to CrateDB from Crystal applications.
7+
:::
8+
9+
:::{rubric} About
10+
:::
11+
12+
[crystal-pg] is a native, non-blocking Postgres driver for Crystal,
13+
building upon [crystal-db].
14+
15+
:::{rubric} Synopsis
16+
:::
17+
18+
`shard.yml`
19+
```yaml
20+
name: cratedb_demo
21+
version: 0.0.0
22+
dependencies:
23+
pg:
24+
github: will/crystal-pg
25+
```
26+
`example.cr`
27+
```crystal
28+
require "db"
29+
require "pg"
30+
31+
DB.open("postgres://crate:crate@localhost:5432/doc?sslmode=disable") do |db|
32+
33+
db.query "SELECT mountain, height FROM sys.summits ORDER BY height DESC LIMIT 3" do |rs|
34+
puts "#{rs.column_name(0)} #{rs.column_name(1)}"
35+
rs.each do
36+
puts "#{rs.read(String)}: #{rs.read(Int32)}"
37+
end
38+
end
39+
40+
end
41+
```
42+
```shell
43+
shards install
44+
```
45+
```shell
46+
crystal example.cr
47+
```
48+
49+
:::{rubric} CrateDB Cloud
50+
:::
51+
52+
For connecting to CrateDB Cloud, use `sslmode=require&auth_methods=cleartext`
53+
parameters, and replace username, password and hostname with values matching
54+
your environment.
55+
```crystal
56+
DB.open("postgres://admin:[email protected]:5432/doc?sslmode=require&auth_methods=cleartext")
57+
```
58+
59+
60+
[crystal-db]: https://github.com/crystal-lang/crystal-db
61+
[crystal-pg]: https://github.com/will/crystal-pg

docs/connect/index.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,20 @@ CrateDB drivers and adapters for supported programming languages, frameworks, an
4949
:margin: 4 4 0 0
5050
:padding: 0
5151

52+
::::{grid-item-card} Crystal
53+
:link: connect-crystal
54+
:link-type: ref
55+
:link-alt: Connect to CrateDB using Crystal
56+
:padding: 3
57+
:text-align: center
58+
:class-card: sd-pt-3
59+
:class-body: sd-fs-1
60+
:class-title: sd-fs-6
61+
```{image} /_assets/icon/crystal-logo.svg
62+
:height: 70px
63+
```
64+
::::
65+
5266
::::{grid-item-card} Java
5367
:link: connect-java
5468
:link-type: ref
@@ -182,6 +196,7 @@ application
182196
:maxdepth: 1
183197
:hidden:
184198
199+
crystal
185200
java
186201
javascript
187202
php

0 commit comments

Comments
 (0)