8000 GitHub - dominion525/jetdb: A pure Rust library for reading Microsoft Access databases (.mdb/.accdb) · GitHub
[go: up one dir, main page]

Skip to content
dominion525Public

About

A pure Rust library for reading Microsoft Access databases (.mdb/.accdb)

Topics

Resources

Stars

12 stars

Watchers

0 watching

Forks

Repository files navigation

jetdb

CI License: MIT OR Apache-2.0 MSRV: 1.87 Crates.io docs.rs

日本語版 (Japanese)

A Rust library and CLI tool for reading Microsoft Access database files (.mdb / .accdb).

Written in pure Rust with no C/C++ dependencies or FFI, so it works out of the box on macOS, Windows, and Linux. Supports Access 97 (Jet3) through Access 2019 (ACE17).

Installation

CLI Tool

cargo install jetdb-cli

As a Library

[dependencies]
jetdb = "0.4"

npm Package

For the browser and Node.js, with TypeScript types. See docs/wasm.md.

npm install jetdb-wasm

CLI Usage

# Open a password-protected .accdb file
jetdb --password secret tables protected.accdb

# Show the database engine version
jetdb ver database.mdb

# List tables
jetdb tables database.mdb

# Show table schema (columns, indexes, relationships)
jetdb schema database.mdb
jetdb schema database.mdb -T Table1

# Generate DDL (SQLite / PostgreSQL / MySQL / Access)
jetdb schema database.mdb --ddl sqlite

# Export table data as CSV
jetdb export database.mdb Table1

# List saved queries / show SQL
jetdb queries list database.mdb
jetdb queries show database.mdb SelectQuery

# List VBA modules / show source code
jetdb vba list database.mdb
jetdb vba show database.mdb Module1

# List forms and reports / show the controls and the design properties of one
jetdb form list database.accdb
jetdb form controls database.accdb Form1
jetdb form props database.accdb Form1

# List named macros / show a macro as SaveAsText text
jetdb macro list database.accdb
jetdb macro show database.accdb AutoExec

# Show the embedded macros of a form or report / the data macros of a table
jetdb macro embedded database.accdb Form1
jetdb macro data database.accdb Table1

# Show object properties
jetdb prop database.mdb Table1

See docs/cli.md for detailed options and output examples.

Library Usage

use jetdb::{PageReader, find_table, read_catalog, read_table_def, read_table_rows, table_names};

fn main() -> Result<(), jetdb::FileError> {
    let mut reader = PageReader::open("database.mdb")?;

    // List tables
    let names = table_names(&mut reader)?;
    for name in &names {
        println!("{name}");
    }

    // Read table definition
    let catalog = read_catalog(&mut reader)?;
    let entry = find_table(&catalog, &names[0])?;
    let table_def = read_table_def(&mut reader, &entry.name, entry.table_page)?;

    // Read row data
    let result = read_table_rows(&mut reader, &table_def)?;
    for row in &result.rows {
        println!("{:?}", row);
    }

    Ok(())
}

For more examples, such as reading forms and reports, macros and object properties, see docs/lib.md. For detailed API documentation, run cargo doc --open or see docs.rs/jetdb.

Supported Versions

Engine Access Version File Format
Jet3 Access 97 .mdb
J 782F et4 Access 2000/2003 .mdb
ACE12 Access 2007 .accdb
ACE14 Access 2010 .accdb
ACE15 Access 2013 .accdb
ACE16 Access 2016 .accdb
ACE17 Access 2019 .accdb

ACE15 is the name of the version byte 0x04, after Access 2013. Access 2013 writes the format of Access 2010 (ACE14), and no file with the byte 0x04 is known; jetdb reads such a file as ACE15.

Features

  • Read table metadata (columns, indexes, relationships)
  • Read row data with Rust type mapping (Text, Long, Double, Timestamp, Money, Memo, OLE, GUID, etc.), all at once or one row at a time
  • Read complex columns: attachments, multiple values, and the history of versions
  • Write table data as CSV
  • Generate DDL for SQLite, PostgreSQL, MySQL, and Access SQL
  • Recover SQL from saved queries
  • Extract VBA module source code
  • Read the design of forms and reports: their properties, and the sections and controls with theirs
  • Read macros: named macros, macros embedded in forms and reports, and data macros, also as the text of SaveAsText
  • Read object properties (LvProp)
  • Decrypt RC4-encrypted databases and password-protected .accdb files (Agile, RC4 CryptoAPI, Standard/NonStandard AES)
  • Handle Jet3 (the code page of the database, such as 1252 or 932) and Jet4+ (UTF-16LE, compressed text) encodings
  • Run on WebAssembly, including the browser target (wasm32-unknown-unknown), by opening a database from bytes in memory with PageReader::open_reader
  • Read databases from JavaScript in the browser and Node.js with the jetdb-wasm package in crates/jetdb-wasm; see docs/wasm.md for its API

Limitations

  • Read-only (no write support)
  • No index-based lookups (full table scan only)
  • Password-protected .accdb files require PageReader::open_with_password (Agile, RC4 CryptoAPI, Standard/NonStandard AES)
  • Replication databases (.mda) are untested

AI Agent Integration

Available as a Claude Code Skill via the agent-skills repository.

Install via Claude Code Plugin Marketplace:

/plugin marketplace add dominion525/agent-skills
/plugin install jetdb-cli@dominion525-skills

Install via Vercel skills CLI:

npx skills add dominion525/agent-skills --skill jetdb-cli -a claude-code

Acknowledgments

  • mdbtools — HACKING.md was an invaluable reference for understanding the MDB/ACCDB file format
  • Jackcess (Apache License 2.0) — most test .mdb/.accdb files are sourced from this project (some were created independently or contributed). See testdata/SOURCES.md for details.
  • jackcessencrypt (Apache License 2.0) — encryption-related test files are sourced from this Jackcess plugin
  • MS-OFFCRYPTO — Microsoft's specification for Office document encryption, used as a reference for implementing encryption support

License

MIT OR Apache-2.0

About

A pure Rust library for reading Microsoft Access databases (.mdb/.accdb)

Topics

Resources

Stars

12 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0