What is the structure of blk001.dat and blkindex.dat? Can anyone tell me where I can read about the structure of the files

 blk0001.dat 
 blk0002.dat
 blkindex.dat


I know that in these files bitcoin is saving all the information about transactions.
I would like to parse the files and save the information from these files in my local database.

[Note-these files are no longer used for Bitcoin-Qt/bitcoind version 0.8 and above.]
While reading the blockchain data directly is possible, you can only do so against stale data files -- as you can't reliably read the files while the client is running.

PyWallet and BitcoinTools are two such methods to do this.

Instead, the Bitcoin.org client (v0.7 and above) provides Raw Transactions support, in which you can decode a transaction to learn of its inputs, outputs and other attributes.  This, along with the rest of the API provides the ability to pull all the data from the blockchain that is needed, against a live instance:


http://en.bitcoin.it/wiki/Raw_Transactions
http://en.bitcoin.it/wiki/Raw_Transactions#decoderawtransaction_.3Chex_string.3E