The following Python code tries to create an SQLite database and a table, using the command line in Linux:
#!/usr/bin/python2.6
import subprocess
args = ["sqlite3", "db.sqlite", "'CREATE TABLE my_table(my_column TEXT)'"]
print(" ".join(args))
subprocess.call(args)
When I ran the code, it created a database with zero bytes and the following output:
sqlite3 db.sqlite 'CREATE TABLE my_table(my_column TEXT)'
Error: near "'CREATE TABLE my_table(my_column TEXT)'": syntax error
But when I copied the command printed by the code (just above the error message), and pasted the command onto the command line, the command created a database with a table.
What is wrong with the code?