Name
Module::Build::DBD:mysql - MySQL specifics for Module::Build::DBD
Description
This module contains a number of class methods called by Module::Build::DB to handle MySQL specific tasks when detecting, building, and updating a database.
Methods
All methods are class methods.
get_client()
my $client = Module::Build::DBD::mysql->get_client;
Returns the name of the client to use to connect to MySQL. For now, that's just mysql
, which is fine if it's in your path. Some code to search for a client might be added in the future. Either way, it's best to specify use the --db_client
option to avoid all ambiguity.
get_db_and_command()
my ($db_name, $cmd) = Module::Build::DBD::mysql->get_db_and_command($client, $params);
Returns a database name culled from $params
and an array reference with $client
and all required options for all access to the database. $params
contains both the contents of the context configuration file's DBI section and the attributes defined in the driver DSN (e.g., database=foo
in dbi:mysql:database=foo
).
get_db_option()
my @opts = Module::Build::DBD::mysql->get_db_option($db_name);
Returns a list of options to be appended to the command returned by get_db_and_command()
to connect to a specific database. For MySQL, that's simply ('--database' => $dbname)
.
get_create_db_command()
my @command = Module::Build::DBD::mysql->get_create_db_command($cmd, $db);
Returns a command list suitable for passing to system()
that will create a new database. $cmd
is the command returned by get_db_and_command()
and $db
is the name of the database to be created.
get_drop_db_command()
my @command = Module::Build::DBD::mysql->get_drop_db_command($cmd, $db);
Returns a command list suitable for passing to system()
that will drop an existing database. $cmd
is the command returned by get_db_and_command()
and $db
is the name of the database to be dropped.
get_check_db_command()
my @command = Module::Build::DBD::mysql->get_check_db_command($cmd, $db);
Returns a command list suitable for passing to system()
that will, when executed, output a 1 when $db
exists and nothing when $db
does not exist. $cmd
is the command returned by get_db_and_command()
and $db
is the name of the database to be checked.
get_execute_command()
my @command = Module::Build::DBD::mysql->get_execute_command($cmd, $db, $sql);
Returns a command list suitable for passing to system()
that will execute the SQL in $sql
and return its output, if any. $cmd
is the command returned by get_db_and_command()
, $db
is the name of the database to be connect to for the query, and $sql
is the SQL command or commands to be executed.
get_file_command()
my @command = Module::Build::DBD::mysql->get_file_command($cmd, $db, $sql);
Returns a command list suitable for passing to system()
that will execute the SQL in $file
and return its output, if any. $cmd
is the command returned by get_db_and_command()
, $db
is the name of the database to be connect to for the query, and $file
is a file with SQL commands.
get_meta_table_sql()
my $sql = Module::Build::DBD::mysql->get_met_table_sql;
Returns an SQL string that creates a metadata table named $table_name
.
Author
David E. Wheeler <david@justatheory.com>
Copyright
Copyright (c) 2008-2010 David E. Wheeler. Some Rights Reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.