Convert SQLite database to XML

一笑奈何 提交于 2019-12-11 01:08:43

问题


Is there any way to convert a .sqlite file to XML?

There exist tools that convert from XML to SQLite, but does are there tools that convert the other way, too?


回答1:


After some experimentation, I found a converter solution using sqlite3:

#!/bin/bash
SFILE="$1"
[ ! -f "$SFILE" ] && echo "$SFILE doesn't exist" 2>&1 && exit 2
for i in $(sqlite3 "$SFILE" '.table'); do
    echo -e ".mode csv\nselect * from $i;" | sqlite3 "$SFILE" > "$i".csv
done

start the script with ./script database.sqlite

Creates for each table via sqlite3 database.sqlite '.table' a tableentry.csv file.

Now to convert csv to xml...



来源:https://stackoverflow.com/questions/24549190/convert-sqlite-database-to-xml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!