Last active
November 28, 2023 13:39
-
-
Save NicolasPA/f4b73ee100c079735531f41bead30ab7 to your computer and use it in GitHub Desktop.
xml2db usage example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from xml2db import DataModel | |
# Create a data model of tables with relations based on the XSD file | |
data_model = DataModel( | |
xsd_file="path/to/file.xsd", | |
connection_string="mssql+pyodbc://server/database?driver=ODBC+Driver+17+for+SQL+Server&trusted_connection=yes", | |
) | |
# Parse an XML file based on this XSD | |
document = data_model.parse_xml( | |
xml_file="path/to/file.xml" | |
) | |
# Insert the document content into the database | |
document.insert_into_target_tables() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment