{"id":16227806,"url":"https://github.com/el3um4s/mdbtools","last_synced_at":"2025-03-19T13:31:10.360Z","repository":{"id":45643206,"uuid":"510710985","full_name":"el3um4s/mdbtools","owner":"el3um4s","description":"MDB Tools - Read Access databases with Node","archived":false,"fork":false,"pushed_at":"2023-01-08T23:30:52.000Z","size":6543,"stargazers_count":9,"open_issues_count":3,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-28T18:48:28.112Z","etag":null,"topics":["access","mdb","ms-access","node","nodejs"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/el3um4s.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["el3um4s"],"patreon":"el3um4s","open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["https://www.paypal.me/el3um4s"]}},"created_at":"2022-07-05T11:41:31.000Z","updated_at":"2024-04-25T11:08:13.000Z","dependencies_parsed_at":"2023-02-08T08:02:22.974Z","dependency_job_id":null,"html_url":"https://github.com/el3um4s/mdbtools","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":"el3um4s/typescript-npm-package-starter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/el3um4s%2Fmdbtools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/el3um4s%2Fmdbtools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/el3um4s%2Fmdbtools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/el3um4s%2Fmdbtools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/el3um4s","download_url":"https://codeload.github.com/el3um4s/mdbtools/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243989730,"owners_count":20379648,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["access","mdb","ms-access","node","nodejs"],"created_at":"2024-10-10T12:53:54.272Z","updated_at":"2025-03-19T13:31:09.298Z","avatar_url":"https://github.com/el3um4s.png","language":"TypeScript","funding_links":["https://github.com/sponsors/el3um4s","https://patreon.com/el3um4s","https://www.paypal.me/el3um4s"],"categories":[],"sub_categories":[],"readme":"# Node MdbTools\n\n[mdbtools](https://github.com/mdbtools/mdbtools) for Node to use MS Access database.\n\nThese aren't native bindings, they just talk to stdin/stdout/stderr of mdbtools.\n\nNPM link: [@el3um4s/mdbtools](https://www.npmjs.com/package/@el3um4s/mdbtools)\n\n### Installation\n\n```\nnpm install @el3um4s/mdbtools\n```\n\n### Requirements\n\nThis package requires [mdbtools](https://github.com/mdbtools/mdbtools) installed on the host system.\n\n**Windows**\n\nDownload and unzip [mdbtools-win](utils/mdbtools-win.zip) (Based on [mdbtools-win](https://github.com/lsgunth/mdbtools-win)).\n\n**Debian**\n\n```\napt install mdbtools\n```\n\n**MacOS**\n\n```\nbrew install mdbtools\n```\n\nThis package is not meant for macOS. It may be that it works like it doesn't.\n\n### Usage\n\n```ts\nimport { versionMdbTools } from \"@el3um4s/mdbtools\";\n\n// in Windows\nconst windowsPath = \"./mdbtools-win\";\nconst versionW = await versionMdbTools(windowsPath);\n\nconsole.log(versionW);\n// mdbtools v1.0.0\n\n// in Linux (Debian)\nconst versionL = await versionMdbTools();\n\nconsole.log(versionL);\n// mdbtools v0.7.1\n```\n\n### API: mdb-ver\n\n`display the version of the specified file`\n\nRequires: mdbtools 0.4+\n\n- `version({ database: \"\",windowsPath?: \"\"}):Promise\u003cstring\u003e` Get the version (JET 3 or 4) of an mdb file\n- `versionMdbTools(windowsPath?: string): Promise\u003cstring\u003e` Get mdbtools version\n\nExamples:\n\n```ts\nconst windowsPath = \"./mdbtools-win\";\nconst database = \"./src/__tests__/fruit.mdb\";\nconst v = await version({ database, windowsPath });\nconsole.log(v);\n// JET4\n```\n\n### API: mdb-tables\n\n`List tables in the specified file`\n\nRequires: mdbtools 0.3+\n\n- `tables({ database: \"\",windowsPath?: \"\"}):Promise\u003cstring[]\u003e` Get the tables in an mdb file (exclude system tables)\n- `tablesAll({ database: \"\",windowsPath?: \"\"}):Promise\u003cstring[]\u003e` Get the tables in an mdb file (include system tables)\n- `tablesSystem({ database: \"\",windowsPath?: \"\"}):Promise\u003cstring[]\u003e` Get the tables in an mdb file (only system tables)\n- `tablesToFile({ database: \"\",windowsPath?: \"\", file: string}):Promise\u003cboolean\u003e` Save the list of tables in a file (exclude system tables)\n- `tablesAllToFile({ database: \"\",windowsPath?: \"\", file: string}):Promise\u003cboolean\u003e` Save the list of tables in a file (include system tables)\n\nExamples:\n\n```ts\nconst windowsPath = \"./mdbtools-win\";\nconst database = \"./src/__tests__/fruit.mdb\";\n\nconst list = await tables({ database, windowsPath });\nconsole.log(list);\n// [ \"Fruit\", \"Fruit Salad\", \"Veggie Salad\", \"Muffin/Bread\", \"Dried\"]\n\nconst listSystem = await tablesSystem({ database });\nconsole.log(listSystem);\n// [ \"MSysObjects\", \"MSysACEs\", \"MSysQueries\", \"MSysRelationships\", \"MSysAccessObjects\", \"MSysNavPaneGroupCategories\", \"MSysNavPaneGroups\", \"MSysNavPaneGroupToObjects\", \"MSysNavPaneObjectIDs\", \"MSysAccessXML\", \"MSysNameMap\" ]\n\nconst file = \"./src/__tests__/__to_file__/tables-fruit.txt\";\nconst t = await tablesToFile({ database, windowsPath, file });\nconsole.log(t);\n// true\n\nconst fileWithSystem =\n  \"./src/__tests__/__to_file__/tables-fruit-with-system-tables.txt\";\nconst ts = await tablesAllToFile({\n  database,\n  windowsPath,\n  file: fileWithSystem,\n});\nconsole.log(ts);\n// true\n```\n\n### API: mdb-queries\n\n`List queries from an Access database`\n\n_The currently implemented SQL subset is quite small, supporting only single table queries, no aggregates, and limited support for WHERE clauses._\n\nRequires: mdbtools 0.9+\n\n- `queries({ database: \"\",windowsPath?: \"\"}):Promise\u003cstring[]\u003e` Get the queries in an mdb file\n- `queriesSQL({ database: \"\",windowsPath?: \"\", query: \"\"}):Promise\u003cstring\u003e` Get the query SQL string\n- `queriesToFile({ database: \"\",windowsPath?: \"\", file: string}):Promise\u003cboolean\u003e` Save the list of queries in a file\n- `queriesSQLToFile({ database: \"\",windowsPath?: \"\", query: \"\", file: string}):Promise\u003cboolean\u003e` Save the query SQL string in a file\n\nExamples:\n\n```ts\nconst windowsPath = \"./mdbtools-win\";\nconst database = \"./src/__tests__/test.mdb\";\n\nconst listQueries = await queries({ database, windowsPath });\nconsole.log(listQueries);\n// [ \"UserA\", \"MainColors\", \"ChangeValueDogTo40\", \"ChangeValueDotTo4\", \"AddApple\", \"DeleteApple\", \"aàeèéiìoòuù\"]\n\nconst s = await queriesSQL({ database, windowsPath, query: \"UserA\" });\nconsole.log(s);\n// SELECT Users.* FROM [Users] WHERE (((Users.UserCategory)=\"A\"))\n\nconst file = \"./src/__tests__/__to_file__/test-queries.txt\";\nconst t = await queriesToFile({ database, windowsPath, file });\nconsole.log(t);\n// true\n\nconst query = \"UserA\";\nconst fileQuery = \"./src/__tests__/__to_file__/test-queries-usera.txt\";\nconst tq = await queriesSQLToFile({\n  database,\n  windowsPath,\n  query,\n  file: fileQuery,\n});\nconsole.log(tq);\n// true\n```\n\n### API: mdb-sql\n\n`A simple SQL engine`\n\n_The currently implemented SQL subset is quite small, supporting only single table queries, no aggregates, and limited support for WHERE clauses._\n\nRequires: mdbtools 0.3+\n\n- `sqlAsString({ database: \"\",windowsPath?: \"\", query: \"\"}):Promise\u003cstring\u003e[]\u003e` Get a SQL Query result (like a string)\n- `sql({ database: \"\",windowsPath?: \"\", query: \"\"}):Promise\u003cRecord\u003cstring, unknown\u003e[]\u003e` Get a SQL Query result (like a JSON array)\n- `sqlToFile({ database: \"\",windowsPath?: \"\", query: \"\", file: \"\"}):Promise\u003cboolean\u003e` Save a SQL Query result in a file\n- `sqlFromFile({ database: \"\",windowsPath?: \"\", inputFile: \"\"}):Promise\u003cRecord\u003cstring, unknown\u003e[]\u003e` Get a SQL Query from a file and return the result (like a JSON array)\n- `sqlFromFileAsString({ database: \"\",windowsPath?: \"\", inputFile: \"\"}):Promise\u003cstring\u003e` Get a SQL Query from a file and return the result (like a string)\n- `sqlFromFileToFile({ database: \"\",windowsPath?: \"\", inputFile:\"\", file: \"\"}):Promise\u003cboolean\u003e` Get a SQL Query from a file and save the result in a file\n\nExamples:\n\n```ts\nconst windowsPath = \"./mdbtools-win\";\nconst database = \"./src/__tests__/test.mdb\";\nconst s = \"SELECT * FROM Colors WHERE Value \u003e 10;\";\n\nconst result = await sql({ database, windowsPath, sql: s });\nconsole.log(result);\n// [\n//     {\n//       Colors: \"Blue\",\n//       Value: \"16\",\n//     },\n//     {\n//       Colors: \"Yellow\",\n//       Value: \"12\",\n//     },\n// ]\n\nconst resultAsString = await sqlAsString({ database, windowsPath, sql: s });\nconsole.log(resultAsString);\n// Colors      Value\n// Blue        16\n// Yellow      12\n\nconst file = \"./src/__tests__/__to_file__/sql result to file.csv\";\nconst q = await sqlToFile({ database, windowsPath, sql: s, file });\nconsole.log(q);\n// true\n\nconst inputFile = \"./src/__tests__/__to_file__/select colors.sql\";\nconst f = await sqlFromFile({ database, windowsPath, inputFile });\nconsole.log(f);\n// [\n//     {\n//       Colors: \"Blue\",\n//       Value: \"16\",\n//     },\n//     {\n//       Colors: \"Yellow\",\n//       Value: \"12\",\n//     },\n// ]\n\nconst fileResult = \"./src/__tests__/__to_file__/sql from file to file.csv\";\nconst rf = await sqlFromFileToFile({\n  database,\n  windowsPath,\n  inputFile,\n  file: fileResult,\n});\nconsole.log(rf);\n// true\n```\n\n### API: mdb-count\n\n`Count rows in a table`\n\nRequires: mdbtools 0.9+\n\n- `count({ database: \"\",windowsPath?: \"\", table: \"\"}):Promise\u003cnumber\u003e` Get the number of rows in a table\n\nExamples:\n\n```ts\nconst windowsPath = \"./mdbtools-win\";\nconst database = \"./src/__tests__/test.mdb\";\nconst table = \"Colors\";\n\nconst c = await count({ database, windowsPath, table });\nconsole.log(c);\n// 7\n```\n\n### API: mdb-json\n\n`Export a table to a JSON array`\n\nRequires: mdbtools 0.9+\n\n- `tableToJson({ database: \"\",windowsPath?: \"\", table: \"\"}):Promise\u003cRecord\u003cstring, unknown\u003e[]\u003e` Export a table to a JSON array\n\nExamples:\n\n```ts\nconst windowsPath = \"./mdbtools-win\";\nconst database = \"./src/__tests__/test.mdb\";\nconst table = \"Colors\";\n\nconst result = await tableToJson({ database, windowsPath, table });\nconsole.log(result);\n// [\n//     { Colors: \"Red\", Value: 10 },\n//     { Colors: \"Green\", Value: 5 },\n//     { Colors: \"Blue\", Value: 16 },\n//     { Colors: \"Black\", Value: 1 },\n//     { Colors: \"Yellow\", Value: 12 },\n//     { Colors: \"White\", Value: 10 },\n//     { Colors: \"Others\", Value: 0 },\n// ]\n```\n\n### API: mdb-export\n\n`Export a table to a CSV string`\n\nRequires: mdbtools 0.1+\n\n- `tableToCSV({ database: \"\",windowsPath?: \"\", table: \"\"}):Promise\u003cstring\u003e` Export a table to a CSV string\n- `tableToCSVFile({ database: \"\",windowsPath?: \"\", table: \"\", file: \"\", options:\"\"}):Promise\u003cboolean\u003e` Export a table to a CSV file\n\nExamples:\n\n```ts\nconst windowsPath = \"./mdbtools-win\";\nconst database = \"./src/__tests__/test.mdb\";\nconst table = \"Colors\";\n\nconst result = await tableToCSV({ database, windowsPath, table });\nconsole.log(result);\n// Colors,Value\n// \"Red\",10\n// \"Green\",5\n// \"Blue\",16\n// \"Black\",1\n// \"Yellow\",12\n// \"White\",10\n// \"Others\",0\n\nconst file = \"./src/__tests__/__to_file__/test-export-colors.csv\";\nconst options = \"-d; -Q\";\nconst t = await tableToCSVFile({\n  database,\n  windowsPath,\n  table,\n  file,\n  options,\n});\nconsole.log(t);\n// true\n```\n\nOptions:\n\n| short | long                  | description                                                                   |\n| ----- | --------------------- | ----------------------------------------------------------------------------- |\n| -H    | --no-header           | Suppress header row.                                                          |\n| -d    | --delimiter=char      | Specify an alternative column delimiter. Default is comma.                    |\n| -R    | --row-delimiter=char  | Specify a row delimiter                                                       |\n| -Q    | --no-quote            | Don't wrap text-like fields in quotes.                                        |\n| -q    | --quote=char          | Use `\u003cchar\u003e` to wrap text-like fields. Default is double quote.               |\n| -X    | --escape=format       | Use `\u003cchar\u003e` to escape quoted characters within a field. Default is doubling. |\n| -I    | --insert=backend      | INSERT statements (instead of CSV)                                            |\n| -N    | --namespace=namespace | Prefix identifiers with namespace                                             |\n| -0    | --null=char           | Use `\u003cchar\u003e` to represent a NULL value                                        |\n| -B    | --boolean-words       | Use TRUE/FALSE in Boolean fields (default is 0/1)                             |\n\n### API: mdb-schema\n\n`Generate DDL for the tables`\n\nRequires: mdbtools 0.1+\n\n- `schema({ database: \"\",windowsPath?: \"\", table: \"\"}):Promise\u003cstring\u003e` Generate DLL schema for all tables\n- `schemaTable({ database: \"\",windowsPath?: \"\", table: \"\"}):Promise\u003cstring\u003e` Generate schema only for a table\n- `schemaToFile({ database: \"\",windowsPath?: \"\", table: \"\", file: \"\"}):Promise\u003cboolean\u003e` Export DLL schema for all tables to file\n- `schemaTableToFile({ database: \"\",windowsPath?: \"\", table: \"\", file: \"\"}):Promise\u003cboolean\u003e` Export DLL schema only for a table to file\n\nExamples:\n\n```ts\nconst windowsPath = \"./mdbtools-win\";\nconst database = \"./src/__tests__/test.mdb\";\nconst s = await schema({ database, windowsPath });\n\nconst table = \"Colors\";\nconst schemaT = await schemaTable({ database, windowsPath, table });\nconsole.log(schemaT);\n// CREATE TABLE [Colors]\n//  (\n//     [Colors]           Text (50),\n//     [Value]            Long Integer\n// );\n```\n\n### API: utilities-columnsName\n\n`Get the columns name of a table`\n\nRequires: mdbtools 0.3+\n\n- `columnsName({ database: \"\",windowsPath?: \"\", table: \"\"}):Promise\u003cstring[]\u003e` Get the columns name of a table\n- `columnsNameTables({ database: \"\",windowsPath?: \"\"}):Promise\u003cRecord\u003cstring, string[]\u003e\u003e` Get the columns name of all tables\n\nExamples:\n\n```ts\nconst windowsPath = \"./mdbtools-win\";\nconst database = \"./src/__tests__/test.mdb\";\nconst table = \"Colors\";\n\nconst columns = await columnsName({ database, windowsPath, table });\nconsole.log(columns);\n// [ \"Colors\", \"Value\" ]\n\nconst allColumns = await columnsNameTables({ database, windowsPath });\nconsole.log(allColumns);\n// {\n//   Users: [\n//     \"UserID\",\n//     \"UserName\",\n//     \"UserSex\",\n//     \"UserBirthday\",\n//     \"UserTelephone\",\n//     \"UserValue\",\n//     \"UserCategory\",\n//   ],\n//   Colors: [\"Colors\", \"Value\"],\n//   Dictionary: [\"Number\", \"Word\"],\n//   \"Colors Table Two\": [\"Colors\", \"Value\"],\n// }\n```\n\n### Known Issues\n\nIn some Windows and Linux configurations it is not possible to read queries and tables with accented characters or symbols such as `°` or `µ`.\n\n### Acknowledgments\n\nSample database used for tests and examples is from [mdb](https://github.com/maxogden/node-mdb).\n\nTo create this package I was inspired by:\n\n- [mdbtools/mdbtools](https://github.com/mdbtools/mdbtools)\n- [maxogden/node-mdb](https://github.com/maxogden/node-mdb)\n- [1withforce/node_mdb_parse](https://github.com/maxogden/node-mdb)\n- [lsgunth/mdbtools-win](https://github.com/lsgunth/mdbtools-win)\n- [nuintun/node-adodb](https://github.com/nuintun/node-adodb) (I forked this in [el3um4s/node-adodb](https://github.com/el3um4s/node-adodb))\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fel3um4s%2Fmdbtools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fel3um4s%2Fmdbtools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fel3um4s%2Fmdbtools/lists"}