diff --git a/docs/connect/index.md b/docs/connect/index.md index 11ad45a3..fa3dc1dc 100644 --- a/docs/connect/index.md +++ b/docs/connect/index.md @@ -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 @@ -258,6 +271,7 @@ javascript php python r/index +raku/index ruby rust/index scala/index diff --git a/docs/connect/raku/index.md b/docs/connect/raku/index.md new file mode 100644 index 00000000..d12beb51 --- /dev/null +++ b/docs/connect/raku/index.md @@ -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. + +:::{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