This script exports all historical data from QuickBooks Desktop using the QuickBooks SDK and saves it into SQLite databases. It supports both raw exports and normalized (1NF) exports, providing flexibility for data analysis.
- Read-Only Data Access: Ensures no changes are made to the QuickBooks file.
- Raw Data Export: Exports data as-is for quick access and analysis.
- Normalized Data Export (1NF): Splits complex data (e.g., transactions with line items) into separate tables for a normalized database structure.
- Dual Export Option: Exports both raw and normalized data into separate SQLite databases if desired.
- Command-Line Interface: Allows flexible usage through command-line options.
- QuickBooks Desktop installed.
- QuickBooks company file open during execution.
- QuickBooks Desktop SDK installed. Download it from Intuit Developer.
- Python 3.x installed.
- Required Python Libraries:
pip install pywin32 lxml
- Install QuickBooks SDK and configure QBXMLRP2 Request Processor.
- Ensure QuickBooks is running and the company file is open.
- Install Python dependencies:
pip install pywin32 lxml
- Save the script as
export_qb_sdk_to_sqlite.py
.
Usage: python export_qb_sdk_to_sqlite.py [OPTIONS]
Options:
-raw Export raw QuickBooks data as-is to a SQLite database.
-1nf Export QuickBooks data normalized to First Normal Form (1NF).
-both Export both raw and 1NF data into separate SQLite databases.
-help Show this usage information.
- Export Raw Data Only:
python export_qb_sdk_to_sqlite.py -raw
- Export 1NF Normalized Data Only:
python export_qb_sdk_to_sqlite.py -1nf
- Export Both Versions:
python export_qb_sdk_to_sqlite.py -both
- View Help:
python export_qb_sdk_to_sqlite.py -help
- Raw Data: Stored in
quickbooks_raw_data.db
. - 1NF Normalized Data: Stored in
quickbooks_1nf_data.db
.
- Raw Tables: Customers, Vendors, Accounts, Transactions.
- Normalized Tables:
Transactions
: Summary of transactions.TransactionLineItems
: Line items linked to transactions.
- Read-Only Access: The script uses read-only queries and cannot modify the QuickBooks file.
- Permissions: QuickBooks will prompt for access permissions during the first run—ensure to allow read-only access.
- Testing: Test the script with a sample QuickBooks file before using it on live data.
- Connection Errors:
- Ensure QuickBooks is running and the company file is open.
- Verify QuickBooks SDK and Request Processor are installed.
- Missing Data:
- Check QuickBooks permissions for the connected app.
- Verify query filters in the script.
- Python Errors:
- Ensure dependencies (
pywin32
andlxml
) are installed. - Run the script in a virtual environment if conflicts occur.
- Ensure dependencies (
This project is licensed under the MIT License.
Contributions and improvements are welcome! Feel free to submit a pull request.
For questions or assistance, contact [your_email@example.com].
Install python and required libraries:
pip install pyodbc sqlite3
Setup Quickbooks ODBC Driver for easier integration:
- Download and install the QOBDC Driver for Quickbooks Desktop from (https://quodbc.com)[QODBC]
- Configure the driver to connect to your Quickbooks Company File
Usage: python export_qb_to_sqlite.py [OPTIONS]
Options:
-raw Export raw QuickBooks data as-is to a SQLite database.
-1nf Export QuickBooks data normalized to First Normal Form (1NF).
-both Export both raw and 1NF data into two separate SQLite databases.
-help Show this usage information.
The table schema produced by the script above is not first normal form (1NF) by default. Here's why:
Potential Repeated Groups:
QuickBooks tables like Transaction might contain fields with multiple values (e.g., line items) in a single record.
Unstructured Data:
Some fields might store unstructured or semi-structured data, such as concatenated lists or JSON-like strings.
To make the schema conform to 1NF:
No Repeating Groups or Arrays:
Ensure that each column contains only atomic (indivisible) values.
Unique Rows:
Each row in the table must be unique, with a primary key.
Single Valued Columns:
Every column must contain a single value for a single row.
You can use any Sqlite database viewer to query the data that you export from Quickbooks.
- DSN Not Found: Ensure that the ODBC Data Source is configured properly
- Quickbooks Errors: Make sure Quickbooks is running and the company file is open
- Permissions: Ensure the user has the necessary permissions in Quickbooks to read data