Coder Social home page Coder Social logo

danpu's People

Contributors

gocom avatar hmoragrega avatar tvb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

danpu's Issues

Import problems

In the case that a php variable is serialized in a field sometimes the import fails.

Currently I don't see why, I try to detect the problem, in the next days.

add include-tables config option

It would be handy to send an array with included tables instead of only excluding the rest.
I.e.: If you want to include only 2 of the 50 tables you wouldn't have to exclude the other 48.

How to correctly check if dump/restore went successful?

Is this the correct way to check if the dump/restore went ok?

            // Lets try to import the dump or catch the error if any.
            try {
                new Import($dump);

                // Send a successfully restored backup message.
                echo "Good job!";
            } catch (Exception $e) {

                // Oops, something went wrong! Let's show the error..
                echo "some error";
            }

Cannot delete or update a parent row: a foreign key constraint fails

I am getting this error while trying to import my dump created by danpu:

SQLSTATE[23000]: Integrity constraint violation: 1217 Cannot delete or update a parent row: a foreign key constraint fails

SHOW ENGINE INNODB STATUS; shows me:
Error: Cannot drop table db.tableX because it is referenced by db.tableY

Now, I know I can work around it by setting foreign_key_checks to false.
https://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_foreign_key_checks

But imo it's a dirty solution and I would like to find a proper solution instead. Ideas?

other adapters?

Will this project support other database adapters such as Postresql and Sql Server?

create database if not exists?

is there a way to enable creating the database name ? I looked at config, import, export libraries, I don't see anything there, this would be a really helpful feature.

Cannot add foreign key constraing

Importing exported database on the exact same mysql database via danpu Export,

following exception thrown

Caught exception: SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint

Implement better temporary file management

Temporary file management would be implemented using rah/eien. This would include:

  • An option, and defaults to, searching automatically for the system's temporary directory. This means the end user doesn't (necessarily) have to care about configuring it.
  • Using temporary files when doing the compressed version of the file. Current the temporary file is streamed to the final location without locking, and due to on-the-fly stream compression, the moving takes longer than simply renaming or copying the file. We should first compress, then move.

exporting/importing takes longer the mysqldump

exporting and importing a database takes longer than CLI mysqldump. Is there a way to speed this up?

Nothing immediate jumps out in Config.php

specifics: mysqldump created a file of 840M and took approximately 1 minute

this library took just over 15 minutes and created a file size of 930 M

Avoid heavy work in constructor

Creating an object does not carry the expectation that something is done behind the scenes. That's not an absolute, though side effects should be kept minimal. Here however, creating the object carries huge side effects, creating a potentially big file or overwriting a database.

Also, you don't necessarily want to do the task at hand right at construction time. Consider dependency injection: component A would get a danpu dumper injected via As constructor. Right now, that isn't possible (or rather it's possible but undesirable, because of the side effect).

Since new Export($foo) is the only public interface of Export it is equivalent to a function call, e.g. danpu_export($foo). Another way that stays in object oriented confines is moving the side effects to a dedicated public method.

Are you open to moving the side effects? It would require new major version, because it would break compatibility.

Remove cache file if backup returns an error

I noticed danpu will place files of 0 bytes (i.e.: Rah_Danpu_CpCOO0) in the temporary folder if the backup fails for any reason (like unable to connect). Those should be removed to keep the working directory clean.

Add transactions to import?

Currently the function executes query by query and fails on one with incorrect syntax. This means that prior queries were executed. So we are left with a half-baked import. Either all or none of the queries should be executed. So maybe it would be a good idea to implement transactions into the import function?

Sorry if this is not how one should suggest this.

protected function import()
	{
		$query = '';
		$this->pdo->beginTransaction();
		try {
			while (!feof($this->file)) {
				$line = fgets($this->file);
				$trim = trim($line);

				if ($trim === '' || strpos($trim, '--') === 0 || strpos($trim, '/*') === 0) {
					continue;
				}

				if (strpos($trim, 'DELIMITER ') === 0) {
					$this->delimiter = substr($trim, 10);
					continue;
				}

				$query .= $line;

				if (substr($trim, strlen($this->delimiter) * -1) === $this->delimiter) {
					$this->pdo->exec(substr(trim($query), 0, strlen($this->delimiter) * -1));
					$query = '';
				}
			}
			$this->pdo->commit();
		} catch (\PDOException $e) {
			$this->pdo->rollBack();
                        // throws \PDOException as Exception to make things easier
			throw new Exception($e->getMessage(), $e->getCode(), $e);
		}
	}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.