Skip to content

Commit 4104f33

Browse files
committed
Driver/Perl: Add dedicated page
1 parent 1d3251e commit 4104f33

File tree

3 files changed

+76
-0
lines changed

3 files changed

+76
-0
lines changed

docs/_assets/icon/perl-logo.svg

Lines changed: 10 additions & 0 deletions
Loading

docs/connect/index.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,21 @@ CrateDB drivers and adapters for supported programming languages, frameworks, an
7373
{material-regular}`javascript;2em`
7474
::::
7575

76+
::::{grid-item-card} Perl
77+
:link: connect-perl
78+
:link-type: ref
79+
:link-alt: Connect to CrateDB using Perl
80+
:padding: 3
81+
:text-align: center
82+
:class-card: sd-pt-3
83+
:class-body: sd-fs-1
84+
:class-title: sd-fs-6
85+
```{image} /_assets/icon/perl-logo.svg
86+
:height: 40px
87+
```
88+
89+
::::
90+
7691
::::{grid-item-card} PHP
7792
:link: connect-php
7893
:link-type: ref
@@ -184,6 +199,7 @@ application
184199
185200
java
186201
javascript
202+
perl
187203
php
188204
python
189205
ruby

docs/connect/perl.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
(connect-perl)=
2+
3+
# Perl
4+
5+
:::{div} sd-text-muted
6+
Connect to CrateDB from Perl applications.
7+
:::
8+
9+
:::{rubric} About
10+
:::
11+
12+
[DBD::Pg] is the PostgreSQL database driver for the Perl DBI module.
13+
14+
:::{rubric} Synopsis
15+
:::
16+
17+
`example.pl`
18+
```perl
19+
use DBI;
20+
use DBD::Pg qw(:pg_types);
21+
22+
$dbh = DBI->connect("dbi:Pg:host=localhost;port=5432;dbname=doc", "crate", "crate", {AutoCommit => 0});
23+
$sth = $dbh->prepare("SELECT region, mountain, height FROM sys.summits ORDER BY height DESC LIMIT 3");
24+
$sth->execute();
25+
26+
$rows = $sth->dump_results();
27+
print($rows);
28+
```
29+
30+
Start CrateDB using Docker or Podman, then compile and invoke example program.
31+
```shell
32+
docker run --rm --publish=5432:5432 crate -Cdiscovery.type=single-node
33+
```
34+
```shell
35+
cpan install DBD::Pg
36+
perl example.pl
37+
```
38+
39+
:::{rubric} CrateDB Cloud
40+
:::
41+
42+
For connecting to CrateDB Cloud,
43+
replace username, password, and hostname with values matching
44+
your environment.
45+
```perl
46+
$dbh = DBI->connect("dbi:Pg:host=testcluster.cratedb.net;port=5432;dbname=doc", "admin", "password", {AutoCommit => 0});
47+
```
48+
49+
50+
[DBD::Pg]: https://metacpan.org/pod/DBD::Pg

0 commit comments

Comments
 (0)