Hello Adam,

thank you.I am totally new to DB access using perl. I have looked at perl DBI 
and DBIx::Class. I can get up to speed on DBI comparatively easily i guess. 
(But), i want to start and stick to DBIx::Class, as i want to eventually use 
Catalyst. Catalyst prefers DBIx::Class, so wanted to start from it.

when i saw CPAN for both I understood DBI methods easily and clearly compared 
to DBIx.
use DBI; $dbh = DBI->connect($dsn, $user, $password, { RaiseError => 1, 
AutoCommit => 0 });

where as in comparison i do not see (even in your example below) anything 
similar in DBIx case. (like)     use DBIx::Class; ... etc.

hence the confusion.

I am so new with using perl with DBI, I have no code yet written (sorry).

Hence I was looking for something simple. which fetches data from tables, uses 
it and then stores some data into tables. as cgi script.


thank you.
Rajeev



________________________________
From: Adam Sjøgren <a...@koldfront.dk>
To: dbix-class@lists.scsys.co.uk
Sent: Friday, July 29, 2011 3:41 PM
Subject: [Dbix-class] Re: using as normal perl module

On Thu, 28 Jul 2011 14:52:35 -0700 (PDT), Rajeev wrote:

> all the examples i see are of using the module in a webapp (built with
> catalyst). I am only trying to use it in my cgi perl programe, but
> finding very less documentation. can someone please refer a URL or
> small script which stores and retrieves data from a table using this
> module plz.

I recently used DBIx::Class in a very simple command-line script that
reads files from the filesystem and stuffs them into the database.

I looked roughly like this:

  #!/usr/bin/perl

  use strict;
  use warnings;
  use utf8;
  use File::Slurp qw(slurp);

  use MessageID::DB;

  my $schema=MessageID::DB->connect('dbi:Pg:dbname=message-id', 'USER', 
'PASSWD', { AutoCommit=>1, pg_enable_utf8=>1 });

  my $transaction=sub {
      while(my $filename=<>) {
          chomp $filename;
          my $article=slurp($filename);
          my $message_id=extract_message_id($article, $filename);
          $schema->resultset('Article')->create({ message_id=>$message_id, 
article=>$article });
      }
  };

  $schema->txn_do($transaction);

It is trivial, but you asked for something that doesn't use Catalyst and
is small (I left out the helper-sub and the error-checking) :-)

Maybe if you show what you have tried and describe what you wanted, it
is easier to get help.


  Best regards,

    Adam

-- 
"Good car to drive after a war"                              Adam Sjøgren
                                                        a...@koldfront.dk

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk

Reply via email to