Skip to content
Snippets Groups Projects
Commit d91f5113 authored by Hervé  MENAGER's avatar Hervé MENAGER
Browse files

add XML import class

parent 2911b167
No related branches found
No related tags found
No related merge requests found
Pipeline #24723 passed
...@@ -8,6 +8,8 @@ from django.core.management import BaseCommand, CommandError ...@@ -8,6 +8,8 @@ from django.core.management import BaseCommand, CommandError
import mysql.connector import mysql.connector
import requests_cache import requests_cache
import click import click
import xml.etree.ElementTree as ET
class MyConverter(mysql.connector.conversion.MySQLConverter): class MyConverter(mysql.connector.conversion.MySQLConverter):
...@@ -158,6 +160,21 @@ class DataFrameImportTask(ImportTask): ...@@ -158,6 +160,21 @@ class DataFrameImportTask(ImportTask):
self.source_count = self.dataframe.shape[0] self.source_count = self.dataframe.shape[0]
class XMLImportTask(ImportTask):
description = "Abstract XML import task"
xmlFile = None
xpathSelector = "*"
def open_data_source(self):
tree = ET.parse(argv[1])
root = tree.getroot()
self.rows = root.findall(self.xpathSelector)
def count_source(self):
self.source_count = len(self.rows)
class ImportCommand(BaseCommand): class ImportCommand(BaseCommand):
help = "Generic command to import data into a django database" help = "Generic command to import data into a django database"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment