Fork me on GitHub

n. Slang a rough lawless young Kuali developer.
[perhaps variant of Houlihan, Irish surname]
kualiganism n

Blog of an rSmart Java Developer. Full of code examples, solutions, best practices, et al.

Saturday, September 10, 2011

Screencast: Database Export with Liquibase

Screencast

This screencast is of me demoing a tool called lbcopy. It is a tool built with liquibase and a few liquibase extensions. The idea is a fast and simple database migration. One of the greatest advantages of this tool is its database agnostic personality. You can export from MySQL and import the schema and content directly into an Oracle database without any modification. The same goes for just about any database.

Another distinguishing concept between this tool and others is that data is exported in its native environment. Not SQL, but a database. When exporting data, an H2 or HSQLDB jar file read-only database is produced. The data can then be observed and queried using a normal database query tool like Aqua Data Studio. This gives users a much better visualization of the data vs. observing raw SQL or a CSV.

That's what I demo here. I demo how to export a database and gain access to the exported data.

2 comments:

  1. this is very cool leo. instead of using an implicit save-to-hsqldb step i'm wondering if it's just the same to configure the hsql/derby/whatever db as the export target directly. or would this complicate the export/import flow? I think there would also be value in generalizing to either a single command line entry point, or top-level task that wraps up the other tasks for the few common use cases, and avoid the ant scripting entirely.

    ReplyDelete
  2. Not sure if this helps or not, but if you were to modify the credentials properties to look something like:

    source.driver: com.mysql.jdbc.Driver
    source.classpath: ./lib/mysql-connector-java-5.1.14-bin.jar
    source.url: jdbc:mysql://localhost:3306/test2
    source.schema: test2
    source.username: test
    source.password: test
    target.driver: org.hsqldb.jdbc.JDBCDriver
    target.classpath: ./lib/hsqldb-2.2.4.jar
    target.url: jdbc:hsqldb:res:work/export/data;shutdown=true
    target.schema: PUBLIC
    target.username: SA
    target.password:

    Then instead of "export-all" don't specify a target. You could probably get away with the following:

    % ant -Dchangelog.directory=changelogs/


    What that will do is it will migrate your entire database into an hsqldb. You can then reuse migrate again as much as you want to.

    ReplyDelete