516 dynamic tables and columns#718
516 dynamic tables and columns#718Simon-Will wants to merge 34 commits intoOpenEnergyPlatform:developfrom
Conversation
c85c1fe to
fc5bfec
Compare
8550e9a to
f31622c
Compare
68eb2ad to
2158b8a
Compare
|
On 19.02.2026 a new public version of the Gesamtdatenexport will have a bugfix concerning attributes in the .xsd files: This will probably have no effect on what you have done already right? |
|
Interesting, thanks for pointing that out, @pt-kkraemer! It shouldn't make any difference for now because we make all attributes except the primary keys nullable anyway. But I'll be sure to check out the difference in the XSD files to make sure I understand that point correctly. As for this whole PR, it's almost ready now as you can see from the checklist. If anyone already has comments on the approach, please let them be heard. I don't think I will make substantial changes to the non-testing code anymore. |
open_mastr/utils/xsd_tables.py
Outdated
|
|
||
| # TODO: Should we really mess with the original column names? | ||
| # The BNetzA "choice" to sometimes write MaStR and sometimes Mastr is certainly confusing, | ||
| # but are we the ones who should change that? |
There was a problem hiding this comment.
We should not be the ones to change that. But sadly we decided to do it anyway several years ago and now have to live with that decision 😮💨
01d3f9d to
9b92e57
Compare
|
I just added some view functionality. Now I'm running the download & import with the current Edit: Looks like it worked. Some column names of course change, but the views that preserve the old table names are in place. |
| dt = datetime.strptime(bulk_date_string, "%Y%m%d") | ||
| stichtag_url = ( | ||
| "https://download.marktstammdatenregister.de/Stichtag/" | ||
| "Dokumentation%20MaStR%20Gesamdatenexport%20" |
There was a problem hiding this comment.
Missing "t" in "Gesamtdatenexport" or? I could not find a link with this particular error on the MaStR site
There was a problem hiding this comment.
Ooh, thanks a lot for catching that!
| ) | ||
| return True | ||
| log.info( | ||
| f"MaStR XML ZIP file already present but missing the following data: {bulk_data_list}" |
There was a problem hiding this comment.
Comprehension question: what happens if only a part of the bulk_data_list is already downloaded? Would we not show here that the whole bulk_data_list is missing? Could be misleading.
Edit: I tested the following case where I first downloaded "biomass" and then ["biomass","wind"] and in the second run "biomass" got downloaded again:

There was a problem hiding this comment.
True! I think I missed the incremental nature of the download when refactoring this part of the code a bit. 😬
I now changed it up a bit more and it should be correct and incremental now.
|
Hi @FlorianK13 and @pt-kkraemer, thanks a lot for your reviews and suggestions! I addressed your comments with the two latest commits. Could you have another look? |
|
I just had the same error as #723 when using the latest pull from your fork @Simon-Will. @FlorianK13 wrote in #723 that this will be fixed, I don't think it does. Maybe we can talk about this in our next dev-meeting? |
|
All discussions resolved. I'm waiting for the 0.17 release and will then update this branch before it can be merged. :) |



A first attempt at creating tables based on the MaStR XSD files.
Checklist until this is really ready:
mastr_table_to_db_modelreturned fromMastr.generate_data_model. E.g. by adding a function that generates a Python code snippet with the SQLALchemy models/tables.Mastr.generate_data_modelreturn SQLAlchemy core tables, not ORM models. They are easy to just print and a user can then copy them to their code & modify them. They are also the best common ground. After all, some users might not use the ORM.format_mastr_table_to_db_tablethat makes printing easy for the user.utils_download_bulk.pybecause I found date handling unnecessarily complex. Add interactive download functionality for MaStR date selection #696 #697 changes the same code and adds support for retrieving available XML download dates. If Add interactive download functionality for MaStR date selection #696 #697 is merged, we have to update this retrieval logic to also retrieve the documentation download dates.Type of change (CHANGELOG.md)
Added
Mastr.generate_data_modelthat downloads the newest MaStR documentation and uses the XSD file to build SQLAlchemy models from the contained definitionsUpdated
Mastr.downloadwith two optional new argumentsmastr_table_to_db_table, with which the user can pass their own database schema, andalter_database_tables, with which the user can preventopen-mastrfrom issuing any DDL statements.Removed
Mastr.translate. The user can now get English table and column names by passingenglish=Trueto thegenerate_data_modelordownloadmethod.Workflow checklist
Automation
Closes #516
Closes #577
PR-Assignee
Reviewer