Skip to content

Instantly share code, notes, and snippets.

@NicolasPA
Last active November 28, 2023 13:39
Show Gist options
  • Save NicolasPA/f4b73ee100c079735531f41bead30ab7 to your computer and use it in GitHub Desktop.
Save NicolasPA/f4b73ee100c079735531f41bead30ab7 to your computer and use it in GitHub Desktop.
xml2db usage example
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