Skip to content

feat: Make primary keys available #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 5, 2024

Conversation

ReubenFrankel
Copy link
Contributor

This feature adds support for primary keys through AccessTable instances . This doesn't change the existing API of AccessParser.parse_table, but does add a new get_table method to expose the underlying AccessTable instance (and subsequently the primary keys via AccessTable.primary_keys).

With examples/test.mdb:

Python 3.7.16 (default, Dec  6 2022, 19:08:09) 
[GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from access_parser import AccessParser
>>> db = AccessParser("examples/test.mdb")
>>> db.catalog
{'MSysObjects': 2, 'ClarotyTable': 18, 'f_AF8292619150475ABBCC3E04860C1240_Data': 22, 'MSysNameMap': 36, 'MSysNavPaneGroupCategories': 44, 'MSysNavPaneGroups': 47, 'MSysNavPaneGroupToObjects': 51, 'MSysNavPaneObjectIDs': 59}
>>> claroty_table = db.get_table("ClarotyTable")
>>> claroty_table.primary_keys
['ID']
>>> claroty_table.parse()
defaultdict(<class 'list'>, {'ID': [1, 2], 'Field1': ['test', 'test2'], 'Field2': ['Claroty', 'Claroty'], 'Field3': ['ICS!', None]})
>>> db.parse_table("ClarotyTable")
defaultdict(<class 'list'>, {'ID': [1, 2], 'Field1': ['test', 'test2'], 'Field2': ['Claroty', 'Claroty'], 'Field3': ['ICS!', None]})

@SharonBrizinov
Copy link
Collaborator

Nice, we'll check this and add comments if needed. Any chance you could upload somewhere the test DB you used?

@ReubenFrankel
Copy link
Contributor Author

@SharonBrizinov Thanks, I tested this change against https://github.com/Matatika/tap-msaccess/blob/a208b5e6ddc4b909c84643271d819c60f8251d72/sample_db/Books.accdb, as well as some customer data and examples/test.mdb in above axample.

@SharonBrizinov
Copy link
Collaborator

lgtm

@SharonBrizinov SharonBrizinov merged commit ff5de09 into claroty:master Feb 5, 2024
@ReubenFrankel ReubenFrankel deleted the feature/primary-keys branch February 5, 2024 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants