Login   Register  
PHP Classes
elePHPant
Icontem

Retrieving, executing and saving partial data from SQL dump: Extract table dumps from full MySQL database dumps

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Info   Screenshots Screenshots   View files View files (5)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings  
2010-09-18 (3 years ago) RSS 2.0 feedNot yet rated by the usersTotal: 328 All time: 6,340 This week: 1,598Up
Version License PHP version Categories  
data-from-dump 1.0BSD License5.0PHP 5, Databases, Systems administration
Description Author  
PHP Programming Innovation award nominee
September 2010
Number 7


Prize: One downloadable e-book of choice by O'Reilly
This class can be used to extract table dumps from full MySQL database dumps.

It can parse a MySQL full database and extract the SQL CREATE and INSERT statements just for given tables.

The extracted SQL statements may be executed immediately or saved to a new database dump file.

Sometimes database administrators or programmers need to restore or copy only a few data tables from one server to another, but all they have is a full DUMP file created by standard utilities like 'dump' (for MySQL).
For production systems it can be really HUGE file, so the task seems to be not so simple.

CDataFromDump class aimed to resolve the problem: it parses source dump file and grabs only data for desired table list. These CREATE TABLES and INSERT operators can be instantly executed on connected database or saved into a new SQL file, for editing and/or executing later.

Currently the class has following features:
- During the first scan, it tries to creates "metadata" file for processed dump, so next retrieving jobs will be much faster.
- Grabs only SQL operators for the tables from passed list
CREATE TABLE operators can be executed/included into result SQL file or NOT, according to passed parameters.
Picture of Alexander Selifonov
Name: Alexander Selifonov is available for providing paid consulting. Contact Alexander Selifonov .
Classes: 15 packages by
Country: Russian Federation Russian Federation
Age: 51
All time rank: 612 in Russian Federation Russian Federation
Week rank: 85 Down5 in Russian Federation Russian Federation Down
Innovation award
Innovation award
Nominee: 11x

Winner: 2x

Screenshots  
  • dfd-screenshot.png
  Files folder image Files  
File Role Description
Plain text file datafromdump.php Class Main class source
Accessible without login Plain text file grabsql.php Example Using example
Accessible without login HTML file datafromdump.en.htm Doc. Documentation (English)
Accessible without login HTML file datafromdump.ru.htm Doc. Documentation (Russian)

Innovation Award  
PHP Programming Innovation award nominee
September 2010
Number 7


Prize: One downloadable e-book of choice by O'Reilly
mysqldump is a tool for taking backups of MySQL databases. It is part of the distribution of MySQL. It works by generating SQL statements that can be used to recreate the database later.

There are several PHP components that do practically the same as the mysqldump command. However, to restore a backup taken with mysqldump usually you execute all the contained SQL statements, and so you have to recreate the whole database.

This class makes the process of restoring MySQL database backups more convenient. It allows recreating only list of database tables of your choice, instead of recreating all.

It even allows saving the relevant SQL statements into a separate file instead of executing them right away. This way you can recreate only the needed tables in multiple steps, eventually in different machines.

Manuel Lemos
 Version Control Unique User Downloads Download Rankings  
 0%Total:328All time:6,340
 This week:0This week:1,598Up