Convert SQLite database to XML

2019-07-17 01:47发布

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条回答
别忘想泡老子
2楼-- · 2019-07-17 02:19

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...

查看更多
登录 后发表回答