Created
October 8, 2009 14:28
-
-
Save melo/205064 to your computer and use it in GitHub Desktop.
Solving a problem for a user in the Lisbon.pm list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Main::Result::Contacto; | |
use base qw/DBIx::Class/; | |
__PACKAGE__->load_components(qw/Core/); | |
__PACKAGE__->table('Contacto'); | |
__PACKAGE__->add_columns(qw/ nome /); | |
__PACKAGE__->set_primary_key('nome'); | |
1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
use Main; | |
use strict; | |
my $schema = Main->connect("dbi:mysql:dbcontacto.db","root","") || die "KABUM"; | |
#my $schema = Main->connect("dbi:SQLite:dbcontacto.db","root","") || die "KABUM"; | |
my @contactos = (['Miguel']); | |
$schema->populate('Contacto', [ [qw/nome/], @contactos, ]); | |
#my @artists = (['Michael Jackson'], ['Eminem']); | |
#$schema->populate('Contacto', [ [qw/nome/], @artists,] | |
#); | |
__END__ | |
sqlite3 dbcontacto.db | |
create table Contacto ( nome varchar(30) ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Main; | |
use base qw/DBIx::Class::Schema/; | |
__PACKAGE__->load_namespaces; | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment