NAME
DBIO::MySQL - MySQL-specific schema management for DBIO
VERSION
version 0.900000
SYNOPSIS
Schema class
package MyApp::Schema;
use DBIO Schema => -mysql;
The -mysql shortcut pins +DBIO::MySQL::Storage as the storage_type and is equivalent to the classic component form below.
package MyApp::Schema;
use DBIO 'Schema';
__PACKAGE__->load_components('MySQL');
Result classes
package MyApp::Schema::Result::Artist;
use DBIO;
__PACKAGE__->table('artist');
__PACKAGE__->add_columns(
id => { data_type => 'integer', is_auto_increment => 1 },
name => { data_type => 'varchar', size => 100 },
);
__PACKAGE__->set_primary_key('id');
__PACKAGE__->has_many(cds => 'MyApp::Schema::Result::CD', 'artist_id');
package MyApp::Schema::Result::CD;
use DBIO;
__PACKAGE__->table('cd');
__PACKAGE__->add_columns(
id => { data_type => 'integer', is_auto_increment => 1 },
artist_id => { data_type => 'integer' },
title => { data_type => 'varchar', size => 200 },
);
__PACKAGE__->set_primary_key('id');
__PACKAGE__->belongs_to(artist => 'MyApp::Schema::Result::Artist', 'artist_id');
Connecting
my $schema = MyApp::Schema->connect($dsn, $user, $pass);
$schema->deploy;
my $artist = $schema->resultset('Artist')->create({ name => 'Sonic Youth' });
my @cds = $artist->cds->all;
For MariaDB use MySQL::MariaDB instead:
__PACKAGE__->load_components('MySQL::MariaDB');
The classic use base form is still supported:
package MyApp::Schema;
use base 'DBIO::Schema';
__PACKAGE__->load_components('MySQL');
DESCRIPTION
DBIO::MySQL is the MySQL driver component for DBIO.
When this component is loaded into a schema class, connection() sets "storage_type" in DBIO::Schema to +DBIO::MySQL::Storage, which enables MySQL-specific storage behavior automatically.
For MariaDB-specific behavior, see DBIO::MySQL::MariaDB and DBIO::MySQL::Storage::MariaDB.
METHODS
connection
Overrides "connection" in DBIO to force +DBIO::MySQL::Storage as storage_type.
MIGRATION NOTES
MySQL storage and SQLMaker classes were split out of the historical DBIx::Class monolithic distribution:
Old:
DBIx::Class::Storage::DBI::mysqlNew:
DBIO::MySQL::StorageOld:
DBIx::Class::Storage::DBI::MariaDBNew:
DBIO::MySQL::Storage::MariaDBOld:
DBIx::Class::SQLMaker::MySQLNew:
DBIO::MySQL::SQLMaker
If DBIO-MySQL is installed, core DBIO::Storage::DBI can autodetect MySQL DSNs and load the new storage class via the driver registry.
TESTING
Integration tests in this distribution use:
DBIO_TEST_MYSQL_DSN
DBIO_TEST_MYSQL_USER
DBIO_TEST_MYSQL_PASS
SQLMaker-focused tests can run offline via DBIO::Test with:
storage_type => 'DBIO::MySQL::Storage'
Replicated-path tests can reuse the same harness with:
replicated => 1,
storage_type => 'DBIO::MySQL::Storage'
AUTHOR
DBIO & DBIx::Class Authors
COPYRIGHT AND LICENSE
Copyright (C) 2026 DBIO Authors Portions Copyright (C) 2005-2025 DBIx::Class Authors Based on DBIx::Class, heavily modified.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.