turicas/rows

Optimize if output format is SQLite

開放

#217 建立於 2017年2月20日

 (0 則留言) (0 個反應) (0 位負責人)Python (136 個分叉)github user discovery
clienhancementhelp wanted

倉庫指標

星標
 (886 顆星)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

If we run the following command:

rows query 'SELECT * FROM table1 WHERE field1="value1"' filename.sqlite --output=out.sqlite

the CLI will:

  • Connect to a SQLite database named filename.sqlite since there's only one source and it's format is SQLite
  • Import the SQLite result into a rows.Table running the query
  • Export the result rows.Table into a new SQLite database named out.sqlite

We can optimize this use case replacing the steps with the following:

  • Connect to a SQLite database named filename.sqlite since there's only one source and its format is SQLite
  • Attach the output database with SQLite's ATTACH SQL command
  • Change the query to have INSERT INTO (to add result to the new database)
  • Run the query

More details on ATTACH in StackOverflow this thread.

貢獻者指南