Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions docs/connect/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,19 @@ Python
R
::::

::::{grid-item-card}
:link: connect-raku
:link-type: ref
:class-body: sd-fs-1 sd-text-center
:class-footer: sd-fs-5 sd-font-weight-bold

```{image} https://upload.wikimedia.org/wikipedia/commons/8/85/Camelia.svg
:width: 40px
```
+++
Raku
::::

::::{grid-item-card}
:link: connect-ruby
:link-type: ref
Expand Down Expand Up @@ -258,6 +271,7 @@ javascript
php
python
r/index
raku/index
ruby
rust/index
scala/index
Expand Down
64 changes: 64 additions & 0 deletions docs/connect/raku/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
(connect-raku)=

# Raku

:::{div} .float-right .text-right
```{image} https://upload.wikimedia.org/wikipedia/commons/8/85/Camelia.svg
:height: 60px
```
:::
:::{div} .clearfix
:::

:::{div} sd-text-muted
Connect to CrateDB from Raku applications.
:::

:::{rubric} About
:::

[Protocol::Postgres] is a sans-io PostgreSQL client for Raku.

Comment on lines +17 to +21
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:::{rubric} Synopsis
:::

`example.raku`
```raku
use v6.d;
use Protocol::Postgres;

my $host = "localhost";
my $port = 5432;
my $user = "crate";
my $password = "crate";
my $database = "crate";

my $socket = await IO::Socket::Async.connect($host, $port);
my $client = Protocol::Postgres::Client.new;
$socket.Supply(:bin).act({ $client.incoming-data($^data) });
$client.outbound-data.act({ $socket.write($^data) });

await $client.startup($user, $database, $password);

my $resultset = await $client.query('SELECT mountain, height FROM sys.summits ORDER BY height DESC LIMIT 3', []);
react {
whenever $resultset.hash-rows -> (:$mountain, :$height) {
say "$mountain: $height";
}
}
```

:::{rubric} Example
:::

Create the file `example.raku` including the synopsis code shared above.

:::{include} ../_cratedb.md
:::
```shell
zef install Protocol::Postgres
raku example.raku
```


[Protocol::Postgres]: https://raku.land/zef:leont/Protocol::Postgres