On Friday  9 Oct 2015 00:26 CEST, Ian Kelly wrote:

> On Thu, Oct 8, 2015 at 4:03 PM, Cecil Westerhof <ce...@decebal.nl> wrote:
>> 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?
>
> That seems fine to me. Alternatively you could pass shell=True to
> Popen and then the original command should work verbatim (but see
> the warnings about using shell=True).

I know about that, but because of the warnings I decided to never use
it.

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to