I've started a project which is more of a proof of concept than anything. It involves pushing stats from a backup server into a MySQL database. The database will then be used to create certain reports.
I've settled on a schema that make sense and I am ready to begin creating the database. This is my first stab at any kind of databse programming, so my question might seem a bit newby-ish.
My question is, is there a way that I can programmatically create my tables from hash keys? I hope so, since doing this manually would take several hours!
Here's example content of one of the hashes that I will use:
In this case, the outer most hash key would be the primary key, named 'jobid', the inner most keys would be column names, and the inner values would be that data to be pushed into each table row.$VAR435 = 273118; $VAR436 = { 'try_1_server' => 'netbackup2', 'jobtype' => 'immediate', 'try' => 1, 'group' => '', 'subtype' => 1, 'try_1_ended' => '1031010812', 'try_1_statuscount' => 12, 'filelistcount' => 1, 'status' => '0', 'try_1_stunit' => 'netbackup2_stu', 'try_1_statusdescription' => 'the requested operation was + successfully completed', 'schedule_type' => 4, 'percent' => '', 'trycount' => 1, 'try_1_kbyteswritten' => 1, 'operation' => '', 'retentionunits' => 3, 'files' => 'D:\\', 'try_1_started' => '1031010638', 'try_1_elapsed' => 174, 'masterserver' => 'netbackup1', 'jobid' => 273118, 'try_1_pid' => 13032, 'kbyteslastwritten' => '0', 'path' => '', 'fileslastwritten' => '0', 'try_1_status' => '0', 'client' => 'esmem', 'server' => 'netbackup2', 'jobpid' => 13032, 'started' => '1031008015', 'class' => 'NT-Main', 'elapsed' => 2797, 'stunit' => 'netbackup2_stu', 'state' => 'done', 'retentionperiod' => 1, 'classtype' => 13, 'try_1_statuslines' => '09/02/2002 19:50:40 - connecting 09/02/2002 19:50:40 - connected; connect time: 000:00:00 09/02/2002 19:50:40 - mounting CC0530 09/02/2002 19:50:40 - mounted; mount time: 000:00:00 09/02/2002 19:50:40 - positioning to file 138 09/02/2002 19:50:40 - positioned; position time: 000:00:00 09/02/2002 19:50:40 - begin writing 09/02/2002 19:50:40 - positioning to file 139 09/02/2002 19:50:40 - positioned; position time: 000:00:00 09/02/2002 19:51:30 - positioning to file 140 09/02/2002 19:51:30 - positioned; position time: 000:00:00 09/02/2002 19:53:20 - end writing; write time: 000:02:48', 'ended' => '1031010812', 'schedule' => 'NT-Differentials', 'try_1_fileswritten' => '0', 'kbytes' => 1, 'owner' => 'root', 'compression' => '0', 'priority' => 10 };
The other problem I just realized as I'm typing this, is that if you notice that there are several entries which refer to "no. of tries". There could be as many as 5 tries per jobid. I suppose that could simply create 5 'try_n' tables, all using 'jobid' as their primary key, no?
Again, this is a first go around for me, so if I've left any pertinent info out or I'm not being clear, please ask for clarification
Edit kudra, 2002-09-05 Added a readmore tag
In reply to MySQL Table Creation using DBI by blink
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |