1 2 3 4 5 6 7 8 9 10 11 12 13 14
| # écriture dans le fichier script de la commande d'importation
pathScript = self.pathDir + '/Donnees/script.sqlite'
data = ".mod csv\n.separator ;\n.import " + pathFichier + " table_tmp"
fichier = open(pathScript,"w")
fichier.write(data)
fichier.close()
# création d'une table temporaire pour l'importation
args = [ "sqlite3", self.pathBD, "create table IF NOT EXISTS table_tmp (un text, deux text, trois text, quatre float, cinq float, six float);" ]
proc=subprocess.Popen(args, shell=False)
proc.wait()
# commande d'exécution du script d'importation
args = [ "sqlite3", self.pathBD, ".read "+ pathScript ]
proc=subprocess.Popen(args, shell=False)
proc.wait() |