Text::CSV::Auto::ExportTo::MySQL - Export a CSV file to MySQL.
use Text::CSV::Auto; use Text::CSV::Auto::ExportTo::MySQL; my $auto = Text::CSV::Auto->new('path/to/file.csv'); my $exporter = Text::CSV::Auto::ExportTo::MySQL( auto => $auto, connection => $dbh, );
Or a simpler interface can be used:
$auto->export_to_mysql( connection => $dbh, );
This module provides the ability to export a CSV file straight in to MySQL without much fuss.
Note that if the table already exists it will be dropped.
The Text::CSV::Auto instance to copy headers and rows from. Required.
Can be either a DBIx::Connector (recommended) or a DBI handle. DBIx::Connector is recommended as it provides a robust connection and transation management layer on top of DBI. Required.
The table name to export to. Defaults to a nicely formatted version of the CSV's file name.
If using DBIx::Connector for the connection then this states what method to use such as "run", "txn", or "svp". Defaults to "svp" which degrades well on non-transactional databases.
If using DBIx::Connector for the connection this this dictates what connection mode to use such as "ping", "fixup", and "no_ping". The default is "fixup".
Returns the SQL that will be used to CREATE the table.
Exports the CSV data to MySQL.
Aran Clary Deltac <email@example.com>
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.