我有一个批处理脚本,它向我显示了真实设备上的 SQLite db 表的内容:
@ECHO OFF
SET packageId=com.brightideahub.motorassistant
SET databaseName=test_event_data.db
SET tableName=test_table
adb shell "su -c 'sqlite3 -header -column /data/data/%packageId%/databases/%databaseName% \"SELECT * FROM %tableName%\"'"
pause
问题是每次数据库更改时,我都必须重新运行此脚本以查看更改。 有没有办法流式传输数据库的内容,类似于 logcat 消息如何实时显示?
此外,我一直在浏览 sqlite3 命令可用的选项。谁能解释一下-batch和-interactive选项究竟做了什么,以及它们是否对我想要实现的目标有用?
sqlite3 -help
Usage: sqlite3 [OPTIONS] FILENAME [SQL]
FILENAME is the name of an SQLite database. A new database is created
if the file does not previously exist.
OPTIONS include:
-bail stop after hitting an error
-batch force batch I/O
-column set output mode to 'column'
-cmd COMMAND run "COMMAND" before reading stdin
-csv set output mode to 'csv'
-echo print commands before execution
-init FILENAME read/process named file
-[no]header turn headers on or off
-help show this message
-html set output mode to HTML
-interactive force interactive I/O
-line set output mode to 'line'
-list set output mode to 'list'
-nullvalue TEXT set text string for NULL values. Default ''
-separator SEP set output field separator. Default: '|'
-stats print memory stats before each finalize
-version show SQLite version
-vfs NAME use NAME as the default VFS