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
10 changes: 10 additions & 0 deletions docs/_assets/icon/perl-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions docs/connect/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,21 @@ CrateDB drivers and adapters for supported programming languages, frameworks, an
{material-regular}`javascript;2em`
::::

::::{grid-item-card} Perl
:link: connect-perl
:link-type: ref
:link-alt: Connect to CrateDB using Perl
:padding: 3
:text-align: center
:class-card: sd-pt-3
:class-body: sd-fs-1
:class-title: sd-fs-6
```{image} /_assets/icon/perl-logo.svg
:height: 40px
```

::::

::::{grid-item-card} PHP
:link: connect-php
:link-type: ref
Expand Down Expand Up @@ -184,6 +199,7 @@ application

java
javascript
perl/index
php
python
ruby
Expand Down
48 changes: 48 additions & 0 deletions docs/connect/perl/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
(connect-perl)=

# Perl

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

:::{rubric} About
:::

[DBD::Pg] is the PostgreSQL database driver for the Perl DBI module.

:::{rubric} Synopsis
:::

`example.pl`
```perl
use DBI;
use DBD::Pg qw(:pg_types);

$dbh = DBI->connect("dbi:Pg:host=localhost;port=5432;dbname=doc", "crate", "crate", {AutoCommit => 0});
$sth = $dbh->prepare("SELECT region, mountain, height FROM sys.summits ORDER BY height DESC LIMIT 3");
$sth->execute();

$rows = $sth->dump_results();
print($rows);
```

:::{include} ../_cratedb.md
:::
```shell
cpan install DBD::Pg
perl example.pl
```

:::{rubric} CrateDB Cloud
:::

For connecting to CrateDB Cloud,
replace username, password, and hostname with values matching
your environment.
```perl
$dbh = DBI->connect("dbi:Pg:host=testcluster.cratedb.net;port=5432;dbname=doc", "admin", "password", {AutoCommit => 0});
```


[DBD::Pg]: https://metacpan.org/pod/DBD::Pg