Perl-mysql: Difference between revisions
Jump to navigation
Jump to search
m Created page with '<source lang=perl> # Connecting to the database my $dbh = DBI->connect('DBI:mysql:euc:127.0.0.1', 'raj', 'treebase') or die $!; # Setting the SQL global limits $dbh->do("SET …' |
mNo edit summary |
||
| (One intermediate revision by the same user not shown) | |||
| Line 6: | Line 6: | ||
# Setting the SQL global limits | # Setting the SQL global limits | ||
$dbh->do("SET GLOBAL max_allowed_packet=16*1024*1024"); | $dbh->do("SET GLOBAL max_allowed_packet=16*1024*1024"); | ||
#Creating the Database | #Creating the Database | ||
| Line 24: | Line 23: | ||
# Insert | # Insert | ||
$dbh->do("INSERT INTO $table (ID, scaf_nr, c_seq, sequence) VALUES ('$i', '$scaf_nr', '$c_seq', '$sequence')" ); | $dbh->do("INSERT INTO $table (ID, scaf_nr, c_seq, sequence) VALUES ('$i', '$scaf_nr', '$c_seq', '$sequence')" ); | ||
</source> | </source> | ||
[[Category:Bioinformatics]] | |||
Latest revision as of 08:02, 27 February 2010
# Connecting to the database
my $dbh = DBI->connect('DBI:mysql:euc:127.0.0.1', 'raj', 'treebase') or die $!;
# Setting the SQL global limits
$dbh->do("SET GLOBAL max_allowed_packet=16*1024*1024");
#Creating the Database
eval { $dbh->do("DROP TABLE IF EXISTS $table") };
$sql = "
CREATE TABLE $table
(ID INT(10) NOT NULL,
scaf_nr VARCHAR(255) NOT NULL,
c_seq VARCHAR(10) NOT NULL,
sequence text NOT NULL,
KEY ID (ID))
ENGINE=MyISAM DEFAULT CHARSET=latin1;
";
$dbh->do($sql);
# Insert
$dbh->do("INSERT INTO $table (ID, scaf_nr, c_seq, sequence) VALUES ('$i', '$scaf_nr', '$c_seq', '$sequence')" );