Taxi::Mysql::Handle - extendable full-text index using mysql: database handles


NAME

Taxi::Mysql::Handle - extendable full-text index using mysql: database handles

(Back to Top)


SYNOPSIS

 ##========================================================================
 ## PRELIMINARIES
 use Taxi::Mysql::Handle;
 ##========================================================================
 ## Constructors etc.
 $ih = $CLASS_OR_OBJ->new(%args);
 ##========================================================================
 ## Connections
 $bool = $ih->dbhok();
 $bool = $ih->ensureConnected();
 $bool = $ih->connected();
 $rc   = $ih->connect();
 undef = $ih->_dbconnect();
 undef = $ih->disconnect();
 ##========================================================================
 ## SQL utilities
 ($sth,$rv)    = $ih->execSQL($sql)              ##-- array context
 $sth          = $ih->execSQL($sql)              ##-- scalar context
 @row_array    = $ih->fetch1row_array($sql);
 $row_arrayref = $ih->fetch1row_arrayref($sql);
 $row_hashref  = $ih->fetch1row_hashref($sql);
 ##========================================================================
 ## Database utilities
 $bool = $ih->dbTableExists($table_or_fullname);
 $bool = $ih->dbTableClear($table_or_fullname);
 $bool = $ih->dbTableDrop($table_or_fullname);
 $bool = $ih->dbTableCreate($table_or_sql);
 $bool = $ih->dbTableLoadDataInfile($table,%options);
 $bool = $ih->dbTableExportDataFileServer($table,%options);
 $bool = $ih->sqlExportDataFile($sql,%args);
 $bool = $ih->dbTableAnalyze($table_or_fullname, %options);
 $bool = $ih->dbTableOptimize($table_or_fullname, %options);

(Back to Top)


DESCRIPTION

Taxi::Mysql::Handle is a wrapper class for various backend MySQL database-related tasks and activities which supports verbose messaging and tracing using Taxi::Mysql::Logger.

Globals

Variable: @ISA

Taxi::Mysql::Handle inherits from Taxi::Mysql::Base.

Constructors etc.

new
 $ih = $CLASS_OR_OBJ->new(%args);

Object structure / keyword %args:

   {
    ##-- SQL connection information
    dsn=>$mysql_dsn,                  ##-- see DBD::Mysql(3pm)
                                      ##   + default "DBI:mysql:database=$ENV{LOGNAME}_db;host=localhost"
    user=>$user,                      ##-- user name [default=undef]
    password=>$password,              ##-- password  [default=undef]
    charset=>$charset,                ##-- mysql charset for server communication (default='binary')
    ##-- verbosity behavior
    verbose => $vlevel,               ##-- See Taxi::Mysql::Base
    dummy   => $bool,                 ##-- don't do anything at all really
    ##-- low-level data
    dbh=>$database_handle,
   }

Connections

dbhok
 $bool = $ih->dbhok();

Returns true iff the handle connection is currently error-free.

ensureConnected
 $bool = $ih->ensureConnected();

Ensures that the handle is connected to the backed database. Returns true on success.

connected
 $bool = $ih->connected();

Returns true iff handle is currently connected to a backend database.

connect
 $rc = $ih->connect();

(Re-)connect to the backend database. Returns true on success.

_dbconnect
 undef = $ih->_dbconnect();

Guts for connect(). Implicitly sets the character set to use for communication with the backend DB to $ih->{charset} if defined.

disconnect
 undef = $ih->disconnect();

Disconnects from the backend DB.

SQL utilities

execSQL
 ($sth,$rv) = $ih->execSQL($sql) ##-- array context
 $sth       = $ih->execSQL($sql) ##-- scalar context

Run some SQL code. Returns a DBI statment handle in scalar context, and additionally the DBI return value for execute() in list context.

fetch1row_arrayref
 $row_arrayref = $ih->fetch1row_arrayref($sql);

Executes an SQL query and fetches a single result row as an ARRAY reference.

fetch1row_hashref
 $row_hashref = $ih->fetch1row_hashref($sql);

Executes an SQL query and fetches a single result row as a HASH reference.

Database utilities

dbTableExists
 $bool = $ih->dbTableExists($table_or_fullname);

Returns true iff the table $table_or_fullname exists. $table_or_fullname may be either the SQL name of a table or a Taxi::Mysql::Table object.

dbTableClear
 $bool = $ih->dbTableClear($table_or_fullname);

Clears all data from $table_or_fullname, which may be either the SQL name of a table or a Taxi::Mysql::Table object.

The table must exist in the backend DB.

dbTableDrop
 $bool = $ih->dbTableDrop($table_or_fullname);

Drops a table $table_or_fullname from the backend DB. $table_or_fullname may be either the SQL name of a table or a Taxi::Mysql::Table object.

The table must exist in the backend DB.

dbTableCreate
 $bool = $ih->dbTableCreate($table_or_sql);

Create a table in the backend DB. $table_or_sql may be either SQL code to create a table or a Taxi::Mysql::Table object.

The table to be created may not exist already.

dbTableLoadDataInfile
 $bool = $ih->dbTableLoadDataInfile($table,%options);

Loads text data into an existing backend table. $table must be a Taxi::Mysql::Table object. See $ih->dbTableLoadDataInfileSQL() for details on known %options.

dbTableExportDataFileServer
 $bool = $ih->dbTableExportDataFileServer($table,%options);

Server-side data export using ``SELECT ... INTO OUTFILE''.

sqlExportDataFile
 $bool = $ih->sqlExportDataFile($sql,%args);

Export query results to a local text file. $sql is the SQL query to be exported. Known %args:

 file       => $filename,  ##-- may be relative to cwd (default="${table_sqlname}.txt")
 fieldsep   => $str,       ##-- field separator string (default="\t")
 linesep    => $str,       ##-- line separator string  (default="\n")
 encoding   => $encoding,  ##-- output encoding   (for encode)
 dbEncoding => $encoding,  ##-- database encoding (for decode)
dbTableAnalyze
 $bool = $ih->dbTableAnalyze($table_or_fullname, %options);

Calls SQL ``ANALYZE TABLE'' on $table_or_fullname. Known %options:

 local  => $bool,      #-- default=false
 binlog => $bool,      #-- default
dbTableOptimize
 $bool = $ih->dbTableOptimize($table_or_fullname, %options);

Calls SQL ``OPTIMIZE TABLE'' on $table_or_fullname. Known %options:

 local  => $bool,      #-- default=false
 binlog => $bool,      #-- default

(Back to Top)


ACKNOWLEDGEMENTS

Perl by Larry Wall.

(Back to Top)


AUTHOR

Bryan Jurish <moocow@ling.uni-potsdam.de>

(Back to Top)


COPYRIGHT AND LICENSE

Copyright (C) 2006 by Bryan Jurish

This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.7 or, at your option, any later version of Perl 5 you may have available.

(Back to Top)


SEE ALSO

perl(1), Taxi::Mysql(3perl),, Taxi::Mysql::Handle::Dummy(3perl), Taxi::Mysql::Connection(3perl).

(Back to Top)

 Taxi::Mysql::Handle - extendable full-text index using mysql: database handles