Skip to content

Commit

Permalink
Simple script to add characters. Added P&P characters.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave Cross committed Oct 2, 2015
1 parent 163ed4e commit 2f2dfcb
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 5 deletions.
13 changes: 13 additions & 0 deletions Literature/lib/Literature/Schema.pm
Expand Up @@ -14,6 +14,19 @@ __PACKAGE__->load_namespaces;
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2015-10-01 20:37:37
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:LLfKaZZTfOORlQkSPO9kIg

sub get_schema {
my $class = shift;

unless ($ENV{LIT_USER} and $ENV{LIT_PASS}) {
die "You must set LIT_USER and LIT_PASS\n";
}

return $class->connect(
"dbi:mysql:database=literature",
$ENV{LIT_USER}, $ENV{LIT_PASS},
{ mysql_enable_utf8 => 1 },
) || die;
}

# You can replace this text with custom code or comments, and it will be preserved on regeneration
__PACKAGE__->meta->make_immutable(inline_constructor => 0);
Expand Down
6 changes: 3 additions & 3 deletions db/literature.dat
Expand Up @@ -60,7 +60,7 @@ UNLOCK TABLES;

LOCK TABLES `fictional_character` WRITE;
/*!40000 ALTER TABLE `fictional_character` DISABLE KEYS */;
INSERT INTO `fictional_character` VALUES (1,'Elizabeth Bennet'),(2,'FitzWilliam D\'Arcy');
INSERT INTO `fictional_character` VALUES (1,'Elizabeth Bennet'),(2,'FitzWilliam D\'Arcy'),(3,'Mr Bennet'),(4,'Mrs Bennet'),(5,'Jane Bennet'),(6,'Mary Bennet'),(7,'Catherine Bennet'),(8,'Lydia Bennet'),(9,'Charles Bingley'),(10,'Caroline Bingley'),(11,'George Wickham'),(12,'William Collins'),(13,'Lady Catherine de Bourgh');
/*!40000 ALTER TABLE `fictional_character` ENABLE KEYS */;
UNLOCK TABLES;

Expand All @@ -70,7 +70,7 @@ UNLOCK TABLES;

LOCK TABLES `fictional_character_appearance` WRITE;
/*!40000 ALTER TABLE `fictional_character_appearance` DISABLE KEYS */;
INSERT INTO `fictional_character_appearance` VALUES (1,22),(2,22);
INSERT INTO `fictional_character_appearance` VALUES (1,22),(2,22),(3,22),(4,22),(5,22),(6,22),(7,22),(8,22),(9,22),(10,22),(11,22),(12,22),(13,22);
/*!40000 ALTER TABLE `fictional_character_appearance` ENABLE KEYS */;
UNLOCK TABLES;

Expand Down Expand Up @@ -121,4 +121,4 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2015-10-02 13:27:31
-- Dump completed on 2015-10-02 14:22:20
4 changes: 2 additions & 2 deletions db/literature.sql
Expand Up @@ -100,7 +100,7 @@ CREATE TABLE `fictional_character` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
Expand Down Expand Up @@ -198,4 +198,4 @@ CREATE TABLE `work_product` (
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2015-10-02 13:27:31
-- Dump completed on 2015-10-02 14:22:20
32 changes: 32 additions & 0 deletions util/load_chars
@@ -0,0 +1,32 @@
#!/usr/bin/perl

use strict;
use warnings;
use FindBin '$Bin';
use lib "$Bin/../Literature/lib";
use 5.010;

use Literature::Schema;

my $sch = Literature::Schema->get_schema;

my $work_rs = $sch->resultset('Work');
my $pp = $work_rs->find({ title => 'Pride and Prejudice' });

while (<DATA>) {
chomp;
$pp->add_to_fictional_characters({ name => $_ });
}

__DATA__
Mr Bennet
Mrs Bennet
Jane Bennet
Mary Bennet
Catherine Bennet
Lydia Bennet
Charles Bingley
Caroline Bingley
George Wickham
William Collins
Lady Catherine de Bourgh

0 comments on commit 2f2dfcb

Please sign in to comment.