diff --git a/docs/_assets/icon/perl-logo.svg b/docs/_assets/icon/perl-logo.svg new file mode 100644 index 00000000..cadaba4f --- /dev/null +++ b/docs/_assets/icon/perl-logo.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/docs/connect/index.md b/docs/connect/index.md index ffe0cae1..82dc5fd3 100644 --- a/docs/connect/index.md +++ b/docs/connect/index.md @@ -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 @@ -184,6 +199,7 @@ application java javascript +perl/index php python ruby diff --git a/docs/connect/perl/index.md b/docs/connect/perl/index.md new file mode 100644 index 00000000..78774554 --- /dev/null +++ b/docs/connect/perl/index.md @@ -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