Skip to content
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

Convert Edk2DB to use an ORM instead of sqlite3 directly #485

Merged
merged 8 commits into from
Jan 19, 2024

Conversation

Javagedes
Copy link
Contributor

@Javagedes Javagedes commented Jan 8, 2024

Edk2DB has a high barrier to entry as users must not only know how to write and work with sqlite3 databases, but also spend the time to understand the schema of the EDK2DB database, which can change depending on user's needs. These changes occur because users can choose to register only a subset of provided parsers, and create their table parsers, which can result in a drastically different database implementation. This change switches database functionality to be managed through an ORM (specifically https://www.sqlalchemy.org/) to abstract away the need to know the inner workings of the database.

This change should greatly reduce the barrier to entry for users that want to utilize this functionality. They only need to learn the simple interface for writing ORM queries (Through the ORM Querying Guide), then they will be able to work with the database tables as if they were traditional python objects.

This change does the following:

  1. Switches Edk2DB to use sqlalchemy instead of sqlite3 (sqlalchemy uses sqlite3).
  2. Removes the Edk2DB context manager as it is no longer necessary
  3. Add Mapped Table objects to edk2toollib.database which represent tables in the database
    • Environment
    • Value
    • Inf
    • InstancedInf
    • Source
    • Library
    • Package
    • Fv
  4. Updates all table generators to use sqlalchemy functionality to insert into the database
  5. Updates documentation

Copy link

codecov bot commented Jan 8, 2024

Codecov Report

Attention: 12 lines in your changes are missing coverage. Please review.

Comparison is base (1069591) 81.26% compared to head (c58e7b0) 81.35%.

Files Patch % Lines
edk2toollib/database/tables/instanced_inf_table.py 85.00% 6 Missing ⚠️
edk2toollib/database/tables/package_table.py 89.65% 3 Missing ⚠️
edk2toollib/database/tables/inf_table.py 92.85% 2 Missing ⚠️
edk2toollib/database/tables/instanced_fv_table.py 93.75% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #485      +/-   ##
==========================================
+ Coverage   81.26%   81.35%   +0.09%     
==========================================
  Files          57       56       -1     
  Lines        7402     7483      +81     
==========================================
+ Hits         6015     6088      +73     
- Misses       1387     1395       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Updates

small update

Update

UPdate

Clean up code

.\.cspell.json

Update

update

Spelling

Update parsing

.\.cspell.json

Fix source and inf paths

Fix source and inf paths

update for logging

Update parsing package table

Separate Repository and Package

reformat

bugfix

Update to log

Update relative paths
@Javagedes Javagedes added this to the v0.20.0 milestone Jan 19, 2024
@Javagedes Javagedes merged commit d87ccb4 into tianocore:master Jan 19, 2024
12 checks passed
@Javagedes Javagedes deleted the orm-conversion branch January 19, 2024 22:44
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