mysql - unix command execution with password via python -


i trying connect mysql in unix python script. provided password connect mysql in script terminal still prompts password. have till now:

import os subprocess import popen, pipe  passwd = "user" command = "mysql -u root -p"  proc = popen(command.split(), stdin=pipe) proc.communicate(passwd+'\n')[1] 

can 1 suggest doing wrong here. or there better way this.

i tried script in ubuntu 14.04. easy start mysql in terminal using shell script. here code..

#!/bin/bash        user=('root') pass=('xxx') mysql -u $user -p$pass echo 'success' 

simply run code & can start mysql @ terminal...


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -