File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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/?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+
43+ :::{include} ../_cratedb.md
44+ :: :
45+ ` ` ` shell
46+ shards install
47+ ` ` `
48+ ` ` ` shell
49+ crystal example.cr
50+ ` ` `
51+
52+ :::{rubric} SSL connection
53+ :: :
54+
55+ Use the `sslmode=require&auth_methods=cleartext` parameters,
56+ and replace username, password,
57+ and hostname with values matching your environment.
58+ Also use this variant to connect to CrateDB Cloud.
59+
60+ ` ` ` crystal
61+ DB.open("postgres://admin:password@testcluster.cratedb.net:5432/?sslmode=require&auth_methods=cleartext")
62+ ` ` `
63+
64+
65+ [crystal-db] : https://github.com/crystal-lang/crystal-db
66+ [crystal-pg] : https://github.com/will/crystal-pg
Original file line number Diff line number Diff line change @@ -75,6 +75,19 @@ Any (ODBC)
7575C#
7676::::
7777
78+ ::::{grid-item-card}
79+ :link : connect-crystal
80+ :link-type: ref
81+ :link-alt: Connect to CrateDB using Crystal
82+ :class-body: sd-fs-1 sd-text-center
83+ :class-footer: sd-fs-5 sd-font-weight-bold
84+ ``` {image} /_assets/icon/crystal-logo.svg
85+ :height: 70px
86+ ```
87+ +++
88+ Crystal
89+ ::::
90+
7891::::{grid-item-card}
7992:link : connect-elixir
8093:link-type: ref
@@ -336,6 +349,7 @@ application
336349:maxdepth: 1
337350:hidden:
338351
352+ crystal/index
339353csharp/index
340354elixir/index
341355erlang/index
You can’t perform that action at this time.
0 commit comments