The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

DBD::Cassandra - Database driver for Cassandra's CQL3

EXAMPLE

    use DBI;

    my $dbh = DBI->connect("dbi:Cassandra:host=localhost;keyspace=test", $user, $password);
    my $rows = $dbh->selectall_arrayref("SELECT id, field_one, field_two FROM some_table");

    for my $row (@$rows) {
        # Do something with your row
    }

    $dbh->disconnect;

DESCRIPTION

DBD::Cassandra is a Perl5 Database Interface driver for Cassandra, using the CQL3 query language.

Class Methods

connect
    use DBI;

    $dsn = "dbi:Cassandra:database=$database";
    $dsn = "dbi:Cassandra:keyspace=$keyspace;host=$hostname;port=$port";
keyspace
database
db

Optionally, a keyspace to use by default. If this is not specified, all queries must include the keyspace name.

hostname

Hostname to connect to. Defaults to localhost

port

Port number to connect to. Defaults to 3306

compression

The compression method we should use for the connection. Currently Cassandra allows lz4 and snappy. We default to lz4, which can be disabled by setting compression=none.

Only used for data frames longer than 512 bytes.

cql_version

There are several versions of the CQL language and this option lets you pick one. Defaults to 3.0.0. Consult your Cassandra manual to see which versions your database supports.

CAVEATS, BUGS, TODO

  • There is currently no support for transactions. begin_work will die if you try to use it.

  • Thread support is untested. Use at your own risk.

  • Not all Cassandra data types are supported. These are currently supported:

    • ascii

    • bigint

    • blob

    • boolean

    • custom

    • double

    • float

    • int

    • text

    • varchar

  • Cassandra/CQL3 is strict about the queries you write. When switching from other databases, such as MySQL, this may come as a surprise. This module supports quote(..), but try to use prepared statements instead. They will save you a lot of trouble.

LICENSE

This module is released under the same license as Perl itself.

AUTHORS

Tom van der Woerdt, tvdw@cpan.org