Skip to main content

qbw-to-sqlite

PyPI version number Test workflow status Download count Changelog License Supported Python versions

Fifteen years ago, Quickbooks was the obvious choice for my small business accounting. I was happy enough to pay the ~$250 every 3 years to get the updates. Then about 5 years ago they decided to drop the desktop version to force everyone online, but I wasn’t interested in paying a monthly fee per company, plus I like having my data local so I can access it on my own terms.

For now, my old (unsupported) QuickBooks (desktop version) limps along, but every so often I think of moving to something else. This is one of those steps: to get access to the transaction history of the file. The (official) SDK would allow much of the access, but it particular, I wanted to be able to see details on bank feed imports, which it’s didn’t expose.

What You Need to Make Use of This

  • a Quickbooks file (.QBW)

  • that Quickbooks files needs a password-less user – If you can still load the file in Quickbooks, you can add one. This is the only piece you need Quickbooks itself for.

  • Python installed

  • SQL Anywhere 17 installed – This is the database engine that Quickbooks uses. You can download a free “Developer Edition”. Python uses the interface it ships. (Offical) SAP Download Linke, (unofficial) Softpedia mirror.

  • (maybe) TheGrideon’s Quickbook Forensics. Their Trial version is fine (and free).

Adding a Password-less User

You can use an existing password-less user if you have one.

  1. Open your Quickbooks file.

  2. Under the menus: Company –> Setup Users and Passwords –> Set Up Users…

  3. You’ll need to provide the adminstrator password on the dialog.

  4. On the “User List” dialog (that should now be open), click “Add User…”

    QuickBooks User List dialog showing the beancount user
  5. Give your user a “User Name”, and leave the password blank. Click “Next”. Click “No” if it asks you if you want to give the user a password. Give it access to “All areas of Quickbooks”. Click “Ok” on the confimation, and the “Finish”.

    QuickBooks user name and password page, password left blank QuickBooks access page with "All areas of QuickBooks" selected

If you name your new user Admin, beancount or minchinweb, the script already has its password. For any other name, generate the password with Quickbooks Forensics:

  1. Open the program. Click on the “UID / PWD” button.

  2. Input your new user’s name.

  3. Click the “Quickbooks 2018-2024” checkbox on the bottom (if applicable)

  4. Copy the UID and PWD for the next step.

    QuickBooks Forensics UID / PWD calculator for the beancount user

How to Run it

Simpliest is the CLI script:

qbw-to-sqlite --qbw "Your Company.QBW" --out your_company.sqlite ^
    --user beancount

Without --user, the built-in logins are tried in turn. Pass --pwd only for a user name the script doesn’t know, or to override its password.

What You Get; Next Steps

You get an SQL dump of your Quickbooks files: ~250 tables of data.

Next, you (or I or us together) need to figure out what all those tables mean. Some will be Quickbook’s internal settings, which we can probably ignore. Many more will be your transactions and so forth: the data of interest. I will try and add notes here as I discover things of note; my searches seem to suggest the database format is basically undocumented.

AI Disclosure

The above portion of the Readme (including this section) was written by me, a human. The rest of the Readme and code was written by an AI, specially Opus 4.8. I tried to use Opus 5.5, but it seemed thrown off by the fact that there was any sort of decryption at all involved to read the database. Hopefully with this code, you won’t run into the same roadblock.

As for the state of the code, it’s at “It (mostly) works for me, on my machine, with my files.” And it would probably still be in that state whether this code had been handcrafted or AI written.

Contributions

Contributions are welcome. If you’re using an AI, make sure it’s behaved.

License

MIT. If you break it, you get to keep both peices ;)

Original (AI) Readme

Convert a QuickBooks Desktop company file (.QBW, or a .QBB backup) into a SQLite database that any SQLite tool can read: pandas, Metabase or sqlite3. The conversion copies every user table with its declared column types and primary keys. It checks row counts, then adds entity views and provenance tables. It needs neither the QuickBooks application nor the Intuit SDK.

Scope. Use this only on company files you are authorized to examine: your own data, or archival, analysis or forensic review you are authorized to perform. It does not crack or recover unknown passwords. It relies on a QuickBooks user you create with no password.

The package is minchin.scripts.qbw_to_sqlite. It is a library first. The qbw-to-sqlite command wraps the same API.

Install

pip install minchin.scripts.qbw-to-sqlite
pip install "minchin.scripts.qbw-to-sqlite[openqbw]"   # optional backend

The default sa backend needs SQL Anywhere 17 on Windows. The package does not install it. SAP offers the Developer Edition free of charge.

Use as a library

from minchin.scripts.qbw_to_sqlite import QBWError, convert

try:
    report = convert(
        r"C:\path\to\Your Company.QBW",
        r"C:\path\to\your_company.sqlite",
        user="beancount",  # optional: omit to try the built-in logins
        tables=["abmc_*"],  # optional: only these tables
    )
except QBWError as exc:
    raise SystemExit(f"conversion did not run: {exc}")

print(report.tables[0].status, report.rows_written)
if not report.ok:
    print("finished with problems:", report.problems)

convert() returns a ConversionReport with the fields output, tables (one TableResult per table, with its status and counts), views, views_skipped, problems, source_sha256 and meta. The ok and rows_written properties summarize them.

convert() raises QBWError when the conversion cannot run at all: the file is missing, the output path is refused, the engine will not start, or no login works. It writes no output in those cases. It raises ValueError for an invalid argument, such as mode="append". A report with problems still means the conversion finished, so check report.ok.

Logging uses the standard logging module, under the logger minchin.scripts.qbw_to_sqlite. The library attaches no handler and configures no logging, so importing it changes nothing in the process.

The docstring of convert lists every argument.

Command line

qbw-to-sqlite --qbw "Your Company.QBW" --out your_company.sqlite ^
    --user beancount

From a checkout, run python qbw_to_sqlite.py with the same arguments, without installing. The command line uses the public API, so minchin/scripts/qbw_to_sqlite/cli.py shows how to call the library.

Option

Meaning

--qbw

.QBW or .QBB company file. Read only, copied, never modified.

--out

SQLite file to create. Refused if it is a QuickBooks file. Replaced atomically, even when the run finishes with problems.

--backend

sa (default) or openqbw (experimental).

--user / --uid / --pwd

SQL Anywhere login (sa backend). With none of them, the built-in logins are tried in turn: Admin, beancount, minchinweb, each in its newer-format and 2017-and-earlier password. --user NAME generates the UID from the name. --uid takes the hex UID directly. --pwd overrides the built-in password.

--mode

replace (default) builds a fresh output and overwrites the old one. merge upserts by primary key into the existing output. Deleted rows are kept, and tables without a primary key gain duplicates. See Re-running on an updated file.

--tables PATTERN

Only tables matching a glob. Matches table or owner.table. Repeatable.

--exclude PATTERN

Skip tables matching a glob. Repeatable.

--limit N

At most N rows per table. Skips the count check.

--where TABLE=PREDICATE

SQL WHERE clause for one table. Passed to SQL Anywhere unchanged, so use it only with trusted input.

--batch-size

Rows per insert batch (default 2000).

--strict

Abort a table on its first bad row, instead of skipping that row.

--sa-dir

SQL Anywhere 17 install folder (found automatically if omitted).

--port / --server

Private TCP port and engine name for the temporary engine.

--work-dir

Where to put the temporary working copy (default: system temp).

--keep-copy

Keep the working copy and engine log.

Exit codes

Code

Meaning

0

Clean. Every selected table is OK or FILTERED.

1

Fatal. No output was written. Examples: wrong password, engine did not start, output path is a QuickBooks file.

2

Usage error.

3

Finished with problems: at least one table is REJECTED_ROWS, PARTIAL, FAILED or MISMATCH.

Backends

Backend

Needs

Output and status

sa (default)

SQL Anywhere 17 install, and a QuickBooks user with no password (one of the built-in names, or your own)

Every selected base table, typed, with views and provenance. Tables that --tables or --exclude leave out are not listed in _qbw_tables. Tested on a sample company file.

openqbw

pip install openqbw (Python 3.10+), no login

Catalog, indexes, transactions and line items only. Experimental. On the sample file it found 643 catalog entries and 0 transactions and 0 line items, so it does not replace sa.

How the sa backend works

.QBW or .QBB --> working copy --dbeng17 -r--> private read-only engine
                 (SHA-256 of                    |  (TCP on a private port)
                  source and copy)              v
                                      sqlanydb (SQL Anywhere's own driver)
                                                |  catalog + SELECT *
                                                v
                                  SQLite  <out>.partial --> atomic rename to <out>
  1. Hash the source (SHA-256), then copy it to a working file. A .QBB backup is extracted first (see QBB backups). The library never opens the original for writing.

  2. Start a private, read-only engine: dbeng17.exe -r -x tcpip(port=...). -r makes the whole server read-only. The library waits for Now accepting requests before it connects.

  3. Connect with sqlanydb, the driver bundled with SQL Anywhere. The library sets the driver’s environment variables only for the import and the connection, then restores them.

  4. Read the catalog. SYS.SYSTAB lists the base tables. SYS.SYSCOLUMN and SYS.SYSDOMAIN give each column’s type, width, scale, nullability and key flag. The library skips system owners (SYS, dbo, …). Real data belongs to QBAdminGroup.

  5. Copy each table in batches, using the declared types and primary keys from the catalog. It checks each row count against COUNT(*) on the source.

  6. Create entity views whose source tables exist.

  7. Write provenance tables, then rename the output into place. A failed run leaves any existing output untouched.

Getting the UID and PWD

QuickBooks stores each user’s database password as a derived value:

PWD = "07" + SHA-256( prepared(password) ) + "00"        (2017-and-earlier form)
UID = the QuickBooks user name encoded as ASCII hex
      e.g. "Admin"     -> 41646d696e
           "beancount" -> 6265616e636f756e74

The prepared(...) step mixes in an Intuit secret that cannot be reproduced offline. The exception is the empty password: its value depends only on the user name. So make a QuickBooks user with no password, and use its blank-password credential.

  1. Make the file writable: attrib -r "Your Company.QBW".

  2. In QuickBooks, log in as Admin and open the company.

  3. Choose Company > Set Up Users and Passwords > Set Up Users > Add User. Name the user, e.g. beancount, leave the password blank, and grant access to all areas.

  4. Exit QuickBooks completely, so the new user is written to disk.

  5. Get the credential. UID is python -c "print('beancount'.encode().hex())". PWD is the blank-password output of the SQL Anywhere database UID & PWD Calculator in Thegrideon QuickBooks Forensics. For the 2017-and-earlier form, it is 68 hex characters of the form 07...00. The newer form is 42 characters starting 06, which the formula above does not describe. The built-in values cover both forms for Admin, beancount and minchinweb.

The same user name gives the same UID and PWD in every company file. If a file’s Admin user has no password, use Admin directly.

QBB backups

A .QBB holds a text header followed by a zlib-compressed company file. The library finds the zlib stream after the Compression_Format=Deflate_ZLIB; marker. It accepts only a stream that inflates to a SQL Anywhere file (magic bytes at offset 20), then converts the result like a .QBW.

Not yet tested on a real backup. No .QBB sample was available. A synthetic container test covers this code path, and the extracted company file matches the one the test built it from.

What the output contains

Data tables

Every selected base table, owned by QBAdminGroup (typically 297 tables). Names mirror the source. Tables from other owners get a prefix, for example QBAdminGroup_abmc_invoice_lineitem. The business data lives in the abmc_* tables. Tables prefixed I_, lm_, tq_, perf_ and patch_ hold QuickBooks internals and are usually small.

Column types and keys

SQL Anywhere domain

SQLite declared type

integer, smallint, bigint, bit, …

INTEGER

float, double

REAL

decimal, numeric, dates, times, char, varchar, …

TEXT

binary, varbinary, long binary, …

BLOB

The library maps DECIMAL and NUMERIC to TEXT on purpose. SQLite’s NUMERIC affinity would convert "12.50" to a float and lose the exact value.

Primary keys go into _qbw_columns. They are enforced by a unique index, <table>__pk, when the copy is clean. The index is not a table constraint, so one bad row cannot abort a table load.

Provenance tables

Table

Contents

_qbw_meta

Tool version, UTC time, source name and size, SHA-256 of the source and of the working copy, backend, mode, filters, views created and skipped, problem list, table and row totals.

_qbw_tables

One row per table: owner, SQLite name, status, source row count, rows read, rows written, rejected rows, primary key, error, note.

_qbw_columns

Column position, source domain, width, scale, nullability, key flag and declared SQLite type.

_qbw_rejected

Rows skipped in lenient mode: table, row number, SQLite error (capped at 10,000 rows).

Table statuses

Status

Meaning

Problem

OK

All rows read and written, and the count matches the source.

no

FILTERED

Copied with --limit or --where, so the count check was skipped.

no

REJECTED_ROWS

Some rows could not be written. They are logged in _qbw_rejected.

yes

PARTIAL

The read failed partway. Rows read before the failure are kept.

yes

FAILED

The table could not be queried, or nothing could be written.

yes

MISMATCH

Rows read or written do not match the source COUNT(*).

yes

Entity views

The library creates these views when their source tables exist. It validates each view after creation. A view that fails to query is dropped and reported as skipped.

View

Built from

Notes

v_invoice_lines

abmc_invoice_header joined to abmc_invoice_lineitem on transaction_id, with customer and item names

One row per invoice line. Lines with no item have item_name NULL.

v_customers

abmc_customer_user

Names with the deleted and hidden flags.

v_items

abmc_item_user

Names, tax code and asset and COGS accounts.

v_accounts

abmc_account_user

Names with the deleted flag.

Only invoices are covered so far. To add bills, checks, sales receipts, payments and journal entries, write the same kind of join, and verify it against the data first.

Re-running on an updated file

The result of running the conversion again on an existing --out file depends on --mode. The default is replace.

replace (default)

Builds a new output from the current company file, then renames it over the old one. The old file is not read, compared or kept. If the run finishes with problems (exit status 3), the new output still replaces the old one. A fatal error leaves the old file untouched. To keep earlier exports, give each run its own name, for example --out your_company_2026-11-20.sqlite, and compare the snapshots.

merge (--mode merge)

Starts from the existing output and upserts each selected table by primary key.

  • Changed rows are overwritten, and new rows are added. For tables with a primary key, a repeat run on an unchanged file gives the same counts.

  • The tool reads full tables and does not detect deletions. Rows deleted in QuickBooks are not removed.

  • If a table’s column names change, the table is dropped and recreated from the new file, so its earlier rows are lost. Its note reads recreated: columns changed since last run.

  • Unselected tables keep their earlier contents.

  • Tables with no primary key gain duplicate rows on every run. Only keyed tables are upserted. In one test, two identical merges of a two-row keyless table produced four rows. Do not merge a dataset that includes keyless tables until this is fixed.

  • The _qbw_* provenance tables are rebuilt on each run, so they describe only the latest run. The output does not record which run wrote which row, and nothing checks that the new company file is the same file as before.

Text encoding

The database declares windows-1252, but QuickBooks stores a mix of UTF-8 and cp1252 bytes in the same database. Currency symbols such as Kč and € are UTF-8. Accented names such as Québec are cp1252. The driver decodes everything as latin-1, which maps every byte and never raises. The library then re-reads each string as UTF-8 when the bytes are valid UTF-8, and as cp1252 otherwise. Without this step, tables with such bytes silently export zero rows.

Caveats

  • The original file is never modified. The engine runs on a read-only copy. The only change to the company file is the QuickBooks user you create. Delete that user afterwards if you do not want it.

  • Logging in runs QuickBooks’ login procedure on the copy, which may update a last-login timestamp. The engine touches the copy, not the evidence file.

  • Different user names give different credentials. Use the same name, such as beancount, to reuse one credential.

  • The ``.DSN`` and ``.ND`` files beside a .QBW belong to QuickBooks. This library does not produce them.

  • SQL Anywhere version. The library targets the SQL Anywhere 17 format that QuickBooks 2018 and later use. The built-in 2017-and-earlier passwords are tried against the same SQL Anywhere 17 engine. That path has not been tested on a real file from those years.

  • Output goes to a ``.<name>.<id>.partial`` file beside ``out``. The library renames it only on completion. A fatal error leaves any existing output untouched.

  • One engine serves one conversion at a time. The driver stays loaded for the life of the process, so the first conversion fixes which SQL Anywhere install the process uses.

Known gaps

  • Page CRC verification. SQL Anywhere’s page checksum is undocumented, so it has not been implemented or verified.

  • Deletion detection in merge mode (see above).

  • Incremental reads from a change cursor. Merge re-reads full tables.

  • AI-agent redaction and audit logging. Out of scope for an extractor.

Development and tests

uv sync
uv run pytest
uv run ruff check . && uv run ruff format --check .

The unit tests use fake source cursors and in-memory SQLite. They need neither a QuickBooks file nor a SQL Anywhere install. The integration tests run the real engine on a copy of the sample file in qb-sandbox/. They run only when SQL Anywhere 17 is installed and both QBW_TEST_UID and QBW_TEST_PWD are set. The openqbw test runs only when openqbw is importable.

Requirements

  • Windows with SQL Anywhere 17 for the sa backend.

  • Python 3.9 or later. CI tests 3.9 and 3.15. Versions in between are best effort. The core uses only the standard library.

  • Optional: openqbw (Python 3.10+) for --backend openqbw.

The library finds the install folder under %ProgramFiles%, %ProgramFiles(x86)% or SQLANY17. Override it with sa_dir or --sa-dir.

Changelog

See CHANGELOG.rst.

License

MIT. See LICENSE.txt.

Metadata

Release files for minchin.scripts.qbw-to-sqlite 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for minchin.scripts.qbw-to-sqlite 0.1.0
File Size Uploaded Provenance Actions
minchin_scripts_qbw_to_sqlite-0.1.0.tar.gz 55.2 kB Without provenance Details for minchin_scripts_qbw_to_sqlite-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for minchin.scripts.qbw-to-sqlite 0.1.0
File Interpreter ABI Platform Actions
minchin_scripts_qbw_to_sqlite-0.1.0-py3-none-any.whl Python 3 none any Details for minchin_scripts_qbw_to_sqlite-0.1.0-py3-none-any.whl

Total release size: 111.7 kB

Release files / minchin_scripts_qbw_to_sqlite-0.1.0.tar.gz

Download URL minchin_scripts_qbw_to_sqlite-0.1.0.tar.gz
Size 55.2 kB
Tags Source
SHA-256 checksum
How to use checksums
997ecd23da91796f941731226d5279d8f0d8cd1f110495d059562b18107749a1
BLAKE2b-256 checksum
How to use checksums
ba0b70b17c6435db38ee97e3dbfe76157a7cf81b8d1971154baf90be4ebb6c59
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.18

Release files / minchin_scripts_qbw_to_sqlite-0.1.0-py3-none-any.whl

Download URL minchin_scripts_qbw_to_sqlite-0.1.0-py3-none-any.whl
Size 56.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5be06b2babfec6641ed6a66ac988e6dba652d1229fa52e3dbadebb37f3d55522
BLAKE2b-256 checksum
How to use checksums
446c13a1d1c148fa103d846e5663ef7a901be0fada1f03b7b39fc82ba6d0c251
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.18

Security for minchin.scripts.qbw-to-sqlite 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page