Skip to content

Instantly share code, notes, and snippets.

@ryan5500
Created August 6, 2009 05:40
Show Gist options
  • Save ryan5500/163157 to your computer and use it in GitHub Desktop.
Save ryan5500/163157 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
#
# Database CRUD test using DBIx::Class module
#
use strict;
use My::Schema;
my $schema = My::Schema->connect('dbi:SQLite:./test.db');
# [C]RUD: create new row at 'Album' table
my $new_album = $schema->resultset('Album')->create({
title => 'Wish You Were Here',
artist => 'Pink Floyd'
});
print "new album title:" . $new_album->title . "\n";
# C[R]UD: read table 'Album' from database
my $album = $schema->resultset('Album')->find(1);
print "album number1 title:" . $album->title . "\n";
# CR[U]D: update Album table's 'title' row
$album->title('sounds bad');
$album->update;
print "album number1 title:" . $album->title . "\n";
# CRU[D]: delete Album table's row
$new_album->delete;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment