Class-Usul

 view release on metacpan or  search on metacpan

lib/Class/Usul/Schema.pm  view on Meta::CPAN

   documentation        => 'When true flips the defaults for yes/no questions',
   short                => 'y';

has 'connect_options'   => is => 'lazy', isa => HashRef,
   builder              => $_build_connect_options;

has 'ddl_commands'      => is => 'lazy', isa => HashRef, builder => sub { {
   'mysql'              => {
      'create_user'     => "create user '[_2]'\@'%' identified by '[_3]';",
      'create_db'       => 'create database [_3] default '
                         . 'character set utf8 collate utf8_unicode_ci;',
      'drop_db'         => 'drop database if exists [_3];',
      'drop_user'       => "drop user '[_2]'\@'%';",
      'exists_db'       => 'select 1 from information_schema.SCHEMATA '
                         . "where SCHEMA_NAME = '[_3]';",
      'exists_user'     => 'select 1 from mysql.user '
                         . "where User = '[_2]' and Host = '%';",
      'grant_all'       => "grant all privileges on [_3].* to '[_2]'\@'%' "
                         . 'with grant option;',
      '-execute_ddl'    => 'mysql -A -h [_1] -u [_2] -p"[_3]" [_5]', },
   'pg'                 => {

lib/Class/Usul/TraitFor/ConnectInfo.pm  view on Meta::CPAN


   -f $file and return $file;

   return catfile( $dir, 'connect-info'.($param->{extension} // CONFIG_EXTN) );
};

my $_get_dataclass_schema = sub {
   return Class::Usul::File->dataclass_schema( @_ );
};

my $_unicode_options = sub {
   return { mysql  => { mysql_enable_utf8 => TRUE },
            pg     => { pg_enable_utf8    => TRUE },
            sqlite => { sqlite_unicode    => TRUE }, };
};

my $_dump_config_data = sub {
   my ($param, $cfg_data) = @_;

   my $ctlfile = $_get_credentials_file->( $param );
   my $schema  = $_get_dataclass_schema->( $param->{dataclass_attr} );

   return $schema->dump( { data => $cfg_data, path => $ctlfile } );
};

lib/Class/Usul/TraitFor/ConnectInfo.pm  view on Meta::CPAN


   ($cfg_data->{credentials} and defined $cfg_data->{credentials}->{ $key })
      or throw 'Path [_1] database [_2] no credentials',
               [ $_get_credentials_file->( $param ), $key ];

   return $cfg_data->{credentials}->{ $key };
};

my $_get_connect_options = sub {
   my $creds = shift;
   my $uopt  = $creds->{unicode_option}
            // $_unicode_options->()->{ lc $creds->{driver} } // {};

   return { AutoCommit =>  $creds->{auto_commit  } // TRUE,
            PrintError =>  $creds->{print_error  } // FALSE,
            RaiseError =>  $creds->{raise_error  } // TRUE,
            %{ $uopt }, %{ $creds->{database_attr} // {} }, };
};

my $_load_config_data = sub {
   my $schema = $_get_dataclass_schema->( $_[ 0 ]->{dataclass_attr} );



( run in 0.542 second using v1.01-cache-2.11-cpan-88abd93f124 )