承接 palmiot/sql-splitter 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

palmiot/sql-splitter

Composer 安装命令:

composer require palmiot/sql-splitter

包简介

Tool for split SQL databases from a file or a pipe.

README 文档

README

Tool for split SQL databases from a file or a stream pipe.

Install

composer require palmiot/sql-splitter

Usage

The basic are two classes, SqlSplitter.php and the extension SqlSplitterCli.php. The first do the hard work while second provide an interface for command line and allow read the output stream pipe directly from mysqldump.

Methods of SqlSplitter

The class have setters and getters for each variable but the work are of the next methods;

$splitter->setFrom('test/fixtures/alldatabases.sql');           // Expect a path or directory of physical file..
$splitter->setTo('./databases');                                // Set the path or directory where save the splitted databases;
$splitter->setPrefix('test');                                   // Set a prefix name for all splitted databases when them save.
$splitter->setData('CREATE DATABASE ... CREATE DATABASE ...');  // Expect an string with all databases.
$splitter->setDatabase('dbname', 'CREATE DATABASE...');         // For add manualy a database.
$splitter->split();                                             // Split and localize action of databases.
$splitter->save();                                              // Save splitted databases on .sql files to output directory.
$splitter->saveJoin();                                          // Save on a single .sql file all databases localized (the result will be similar to source).
$splitter->getLog();                                            // List all exception messages if occurred.
example
include('vendor/autoload.php'); // Using composer

use Palmiot\SqlSplitter\SqlSplitter as Splitter;

$splitter = new Splitter();
$splitter->setFrom('test/fixtures/alldatabases.sql');
$splitter->setTo('databases');
$splitter->setPrefix('test');
$splitter->split();
$splitter->save();
$splitter->saveJoin();
foreach($splitter->getLog() as $entry){
    print($entry->getMessage());
}

The class SqlSplitterCli

The job of this class is listen params or arguments and prepare them for pass to parent class (SqlSplitter) for finally request the work and return a result as string format.

The __construct can listen arguments (see bellow) as array format before pass to parent. The caller is the method run(). The basic usage is this;

cli.php
include('src/SqlSplitter.php');
include('src/SqlSplitterCli.php');  // Including manually (if not use composer)

$work = (new Palmiot\SqlSplitter\SqlSplitterCli([]))->run();    // Listen and work

print($work);   // STDOUT

Once this file been written, we can send the next params from command line;

****************************************************************************************************************
************************************************* SQL Splitter *************************************************
****************************************************************************************************************
*                                                                                                              *
*      -i :: File .sql with all databases                                                                      *
*      --input :: /path/alldatabases.sql                                                                       *
*                                                                                                              *
*      -s :: Stream of databases                                                                               *
*      --stream :: The output of mysqldump directly                                                            *
*                                                                                                              *
*      -o :: Folder where will save the splitted databases                                                     *
*      --output :: /save/here/                                                                                 *
*                                                                                                              *
*      -p :: Apply a generic prefix for all splitted databases                                                 *
*      --prefix :: test                                                                                        *
*                                                                                                              *
*      -j :: Save all dump                                                                                     *
*      --join :: Also save the all databases as a file                                                         *
*                                                                                                              *
*      -l :: Display logs                                                                                      *
*      --logs :: if something goes wrong                                                                       *
*                                                                                                              *
*      Usage:                                                                                                  *
*                                                                                                              *
*      // from input file                                                                                      *
*      $ php cli.php -i alldatabases.sql -o databases -p test -j -l                                            *
*                                                                                                              *
*      // from dump directly                                                                                   *
*      $ mysqldump -P port -h ip -u user -ppass --opt --all-databases | php cli.php -s -o databases -j -l      *
*                                                                                                              *
****************************************************************************************************************

统计信息

  • 总下载量: 6
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-10-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固