-5

my aim is to create a database and use a regular commands in strawberry perl...

Many are saying "StrawberryPerl comes bundled with drivers for MySQL" how to setup the necessary development environment... how to start? and where to start???

simbabque
  • 53,749
  • 8
  • 73
  • 136
Sahi
  • 1
  • 1
  • [DBD::mysql](http://p3rl.org/DBD::mysql) – choroba Nov 04 '15 at 14:24
  • 1
    A driver for MySQL is not a database server. It's just the thing in between Perl and the DB server that lets you talk to the DB. You will need an actual MySQL server. If you don't have that and feel it is too complicated, maybe take a look at sqlite. – simbabque Nov 04 '15 at 16:14
  • What are "regular commands"? – Matt Jacob Nov 04 '15 at 16:54

1 Answers1

2
use DBI qw( );

my $dsn = "dbi:mysql:database=$database";
my $dbh = DBI->connect($dsn, $user, $password, {
   AutoCommit => 1,
   PrintWarn  => 1,
   PrintError => 0,
   RaiseError => 1,
});

If the database server is on another machine, add ";host=$hostname" to the DSN.

If the database server is on a port other than the default, add ";port=$port" to the DSN.

Refer to DBI's documentation for how to issue queries.

ikegami
  • 367,544
  • 15
  • 269
  • 518