Code Monkey home page Code Monkey logo

sqldump's Introduction

SQLDump

GNU Lesser General Public License, v3 Maven Central CI

Utility to dump schema and data from a RDBMS. Features:

  • Does schema-dumping, using (mainly) standard java API, by way of java.sql.DatabaseMetaData
  • Does data-dumping (formats: csv, xml, html, json, sql 'insert into', sql 'update by PK', fixed column size, blob)
  • Can be used with any JDBC-compliant databases
  • Generates Entity-Relationship diagrams based on Tables and FKs (graphML output - yEd recommended)
  • Flexible schema output patterns (based on schema name, object type and object name)
  • Translation of metadata (column types) between different RDBMS dialects/implementations (partial)

SQLDump also has three subprojects:

Author: Telmo Brugnara <[email protected]>

License: LGPLv3 - see LICENSE

SQLDump - Basic Process

SQLDump processing consists of:

  1. 1 Grabber (implementation of SchemaModelGrabber, grabs a SchemaModel)
  2. 'n' Processors (implementation of Processor, usually uses a Connection or SchemaModel) & Dumpers (implementation of SchemaModelDumper, dumps a SchemaModel)

Grabber can be:

  • JDBCSchemaGrabber - Grabs schema metadata from a JDBC connection
  • JAXBSchemaXMLSerializer - Grabs schema metadata from a XML file
  • JSONSchemaSerializer - Grabs schema metadata from a JSON file

Processors can be:

  • DataDump - Dumps data based on grabbed schema (can partition data from 1 table in different files, can dump in different formats)
  • SQLQueries - Dumps data based on SQL-queries (same as DataDump - for each query)
  • CascadingDataDump - Dumps data based on table relationships (FKs), given initial tables/filters
  • graph.ResultSet2GraphML - Dumps a graphML diagram based on a SQL-query
  • SQLDialectTransformer - Transforms schema models between different sql-dialects
  • SQLRunProcessor - Loads properties into SQLRun and execute statements & importers
  • mondrianschema.Olap4jMDXQueries - Dumps data from olap4j/mondrian engine
  • mondrianschema.MondrianSchema2GraphProcessor - Dumps a graphML diagram based on a Mondrian Schema file
  • mondrianschema.MondrianSchemaValidator - Validates a mondrian schema
  • xtraproc.StatsProc - Grabs statistics from database

Dumpers can be:

  • SchemaModelScriptDumper - Dumps schema model in SQL-script format (DDL)
  • JAXBSchemaXMLSerializer - Dumps a XML representation of the schema model
  • JSONSchemaSerializer - Dumps a JSON representation of the schema model
  • graph.Schema2GraphML - Generates a Entity-Relationship diagram based on schema model
  • mondrianschema.MondrianSchemaDumper - Generates a Star/Snowflake Mondrian Schema based on schema model
  • xtradumpers.AlterSchemaSuggester - Generates suggestions of SQL-scripts for altering the schema model (beta)
  • xtradumpers.DropScriptDumper - Generates drop SQL-scripts

All processing is controlled by a properties file. See sqldump.template.properties for more info.

Usage examples can be found at doc/examples.

Dependencies

Building from sources (with ant & ivy)

  • Run git clone https://github.com/tbrugz/sqldump <project-dir> (if not done already)
  • Run ant prepare
  • Install Ivy (mkdir -p $HOME/.ant/lib + curl -o $HOME/.ant/lib/ivy-2.5.0.jar https://repo1.maven.org/maven2/org/apache/ivy/ivy/2.5.0/ivy-2.5.0.jar) or ant ivy-install (if not done already)
  • (obsolete - see ivy-install) Add to project dir an ivysettings.xml file that points to the sqldump maven repo (like this ; better: cp templates/ivysettings.xml ivysettings.xml)
  • (obsolete - see ivy-install) Copy templates/build.properties to build.properties
  • (optional) Edit build.properties
  • (optional/eclipse) Use IvyDE, import project, right click + Ivy > Resolve
  • Run ant resolve
  • (optional) ant test
  • Run ant dist or ant publish (publishes, by default, to local maven repo: $HOME/.m2/repository) or ant all
  • (optional) Publish maven artifacts: Install Maven Ant tasks (curl -o $HOME/.ant/lib/maven-ant-tasks-2.1.3.jar https://repo1.maven.org/maven2/org/apache/maven/maven-ant-tasks/2.1.3/maven-ant-tasks-2.1.3.jar) or ant mvn-ant-tasks-install & ant publish-mvn-files

Running (with sources)

  • Download jdbc jars for your database of choice
  • Edit sqldump.properties
  • Run ant run or
  • Run tbrugz.sqldump.SQLDump, e.g., java -cp bin;lib/kmlutils.jar;lib/commons-logging-1.1.1.jar;lib/log4j-1.2.15.jar;<jdbc-driver-path> tbrugz.sqldump.SQLDump <options>

Not building? Setup env (without sources)

Running (without sources)

  • Download jdbc jars for your database of choice
  • (windows) Run sqldump.bat
  • (unix-like) Run sqldump.sh or run tbrugz.sqldump.SQLDump, e.g., java -cp sqldump.jar:lib/kmlutils.jar:lib/commons-logging-1.1.1.jar:lib/log4j-1.2.15.jar:<jdbc-driver-path> tbrugz.sqldump.SQLDump <options>

Building maven 'modules'

  • ant mvn-modules-install (sqlmigrate & sqldump-mondrian modules)

Building or running with Docker

Command-line options

  • -propfile=<path-to-prop-file>: loads a different config properties file
  • -propresource=<path-to-resource>: loads a different config properties resource
  • -D<property>[=<value>]: define property with value
  • -usesysprop=[true|false]: loads system properties besides the config file properties (default is true)
  • --help: show help and exit
  • --version: show version and exit

Artifact repositories

Releases:

Snapshots:

Maven dependency config:

<dependency>
	<groupId>org.bitbucket.tbrugz</groupId>
	<artifactId>sqldump</artifactId>
	<version>0.9.17</version>
</dependency>

Publishing

Misc/End notes

To build with Jenkins, see doc/jenkins-config.md

To use with Eclipse, IvyDE is recommended

sqldump's People

Contributors

tbrugz avatar

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.