0

I'd like to run a sqlite3 query from a monkeyrunner script of mine.

Ideally I'd like to be able to write code like this:

device = MonkeyRunner.waitForConnection()
sql_query = "select * from myTable;"
device.shell("sqlite3 /path/to/db/ --sql " + sql_query)

Is there an easy way to get sqlite3 execute some SQL passed in as an arg (as apposed to opening an interpreter)?

will
  • 3,103
  • 4
  • 25
  • 30

1 Answers1

0

The syntax for sqlite3 command line is sqlite3 [OPTIONS] FILENAME [SQL]. So you can do something along the lines of

sqlite3 /path/to/db 'select * from foo;'
laalto
  • 150,114
  • 66
  • 286
  • 303