Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: How to display all the content of the database?

by Starky (Chaplain)
on Jan 09, 2003 at 18:46 UTC ( #225605=note: print w/replies, xml ) Need Help??

in reply to How to display all the content of the database?

Rather than answer the question directly, I'd like to ask some questions about the question.

Display of "all the content of the database" "no matter how deep it goes"? If you want a generic script that recurses through foreign keys to display data, then consider 2 possibilities:

  1. Your database has a large number of tables with a large number of associations. You will potentially be writing out a massive stream of data. Why would you want to have such a massive file? Either for archiving or for a human to use.
    • Is it for a human to look at? How many trees would you sacrifice to print out a sizable chunk of a 5 gig database? How would a human find something in the file? Wouldn't it be better just figuring out what the human wants to know and writing some nice queries for them?
    • Is it for archiving? Then why not just dump the database (e.g., via mysqldump)?
  2. Your database is small with a small number of tables. In this case, why not just write a one-off script? You can change it later if you need to rerun it after a change to the schema is made. Trying to conceive of the general case with a recursive search through the data dictionary just seems like it will take alot of time. And recursive code is never the most readable if someone else needs to work with it later. There is a time and place for quick one-off hacks, and this may be one of them.

Although I don't know exactly what it is you are trying to do, my impression is that reanalyzing your initial approach may be fruitful.

Hope this helps :-)

  • Comment on Re: How to display all the content of the database?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://225605]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (3)
As of 2018-06-19 00:16 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (111 votes). Check out past polls.