I want to do the following Bash command in Python:
sqlite3 spreekwoorden.sqlite "SELECT spreekwoord FROM spreekwoorden;" |
sort > spreekwoorden2.txt
The following does this in Python:
sqlite_pipe = Popen(
(
'sqlite3',
'spreekwoorden.sqlite',
'SELECT spreekwoord FROM spreekwoorden;'
),
stdout = PIPE
)
Popen(
(
'sort',
'--output=spreekwoorden2.txt',
),
stdin = sqlite_pipe.stdout
)
Is this the correct way, or is there a better way?
By the way: I want this because I just filled the table spreekwoorden
in my Python script and want to save it immediately.
--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof
--
https://mail.python.org/mailman/listinfo/python-list