how to export mysql tableinfo with perl?

  • Hey - turns out IRC is out and something a little more modern has taken it's place... A little thing called Discord!

    Join our community @ https://discord.gg/JuaSzXBZrk for a pick-up game, or just to rekindle with fellow community members.

May 10, 2003
2,884
0
Germany
Yo!
I'm sitting at work atm and I'm supposed to write a script which exports certain infos out of a mysql table into html documents.

However, I never really worked with Perl, UNIX and mysql (or databases in general...).
Somehow I managed it though to write a script which creates the html files and inserts the values I entered in the perl script.

Now I'm pretty much stuck because I got no clue how to insert the mysql infos.
I want to fill $whatever with: "database: doesntmatter; table: whocares; id: 2; row 6; col 5" is that even possible? Allready Googled it but the most things i found caused me headache. :hangover:
 
Huh? What are you trying to do again? Insert a new record into a table?
 
This tutorial page for perl contains a sample of query to one mysql DB, look for "PERL - MySQL SELECT Query" sample.

mysql DB is a "Relationnal" database system. This implies that at some point you will have to write an adequate "SELECT" SQL statement to read rows of data from your mysql table.

Code:
# DEFINE A MySQL QUERY
$myquery = "SELECT * FROM $tablename";

In this brief sample you will retrieve ALL columns (meaning of '*' character) of ALL rows within the table whose name matches the text string contained in '$tablename' variable.

A SELECT statement always ends with a semi-colon and is made of "clauses": SELECT, FROM, WHERE. On the net you will find loads of samples of SQL SELECT queries that look like this.
Code:
SELECT <comma_separated_columns> FROM <table> WHERE <condition_on_columns>;

Here is one that would display clans with positive or zero streak, concretely those that did not loose the last match if any.
Code:
SELECT clan, points, won, drawn, lost, streak, leaguetype
FROM t_clans
WHERE leaguetype = 'PROAS';

You might learn more googling "select statement" or "Perl select mysql"
 
Last edited: