himselfv / jet-tool

MS Jet database schema export/SQL execution tool
21 stars 3 forks source link

jet-tool

This tool lets you dump MS Access/MS Jet database schema as an SQL file containing the commands needed to recreate the database from the scratch.

It also lets you execute those files, or any other SQL files, or SQL commands from keyboard.

Usage information is available by doing "jet help".

Syntax

Syntax: jet <command> [params]

Available comands

Connection options

There are three ways to specify database connection. Some are less preferable than others because they're limited in what you can do. For certain operations this tool uses DAO, which cannot connect to Jet databases by anything other than file name (and cannot connect to ANY databases by ADO ConnectionString).

If the tool cannot use DAO, it'll silently disable the optional features relying on it, but if you explicitly enable those through the command-line it'll fail.

Database connection options:

Database format:

By default the tool guesses by the file name (assumes jet4x MDBs unless the extension is accdb). Examples:

Accdb format support requires newer providers installed. The best compatible available providers will be auto-selected, you can override this:

What to include in dumps:

Limit dump to only selected tables: --data table1,table2 (--no-tables table1 not allowed).

Shortcuts: --all, --none, --default; may be overriden: --all --no-procedures

Additional options:

By default, Jet gives no way to set table/field comments ("descriptions" you write for them in MS Access) via SQL. They can be read though. If you enable this, they will be dumped in SQL file, but how they'll be dumped, that depends.

By default they're dumped just as comments, which means, when you execute the resulting SQL they will be ignored. With --private-extensions on, they're dumped in a private comment format:

  /**COMMENT* [content] */

If, and only if, you execute the SQL file with Jet-tool, these comments will be parsed and the tool will manually set the field/table/view "descriptions" via DAO. Consequently, you'll also need Filename-type connection, when executing.

Back to dumping options:

If you specify none of the above options, default dump takes place:

--tables --views --comments --relations --procedures --drop --private-extensions

Misc options

If you cannot redirect input and output through the usual command-line piping you can use I/O redirection options:

Logging options:

Error handling:

Input handling in EXEC:

In CRLF-Break mode ';' is still considered a command terminator. 'asd;bsd[return]' will result in two commands being executed, 'asd' and 'bsd'.

By default when the tool is sure input is not redirected (comes from console), these are set:

--verbose --ignore-errors --crlf-break

When the tool is unsure and thinks the input might be coming from file, these are set:

--stop-on-errors --no-crlf-break

You can explicitly set these options via command-line in which case no guessing is made.

Additional information

See FAQ for frequently asked questions and problems.

See Limitations of what the tool can support in the database.

Development

This tool is written in Object Pascal and should probably compile on Delphi 2005+ or compatible FreePascal. If you want to build it from the sources, see Building notes.

This tool is not being actively developed, but you can contact me if you need an option which is not available.

If you're interested in contributing, feel free to join.