Perl-mysql

From RAJ INFO
Revision as of 08:00, 27 February 2010 by Raj (talk | contribs) (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 …')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
# 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')"	);