Perl DBI – Some usefull commands

Return a reference to column names

$name = $sth->{NAME};

Number of affected rows

$sth->rows();

New auto-incremented id

$latestId = $dbh->{‘mysql_insertid’}

Uploading large data. ‘INSERT INTO’ command takes long amount of time. Use ‘LOAD DATA’ command to upload bulk data from a text file.

  • Be careful. If the file to be uploaded resides on the server, it still needs to be accessible by the mysql server. E.g. you can place them under /tmp
  • You can specify NULL characters by ‘\N’, e.g. “9,\N,276,John…”
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: