hiaips wrote: > damacy wrote: > > hi, there. i have this question which might sound quite stupid to some > > people, but here we go anyway. > > > > i have written a python program which interacts with a postgresql > > database. what it does is simply drops an existing database called > > 'mytempdb'. > > > > the code looks like below; > > > > link = subprocess.Popen(command, stdin = subprocess.PIPE, stdout = > > subprocess.PIPE, shell = True) > > link.communicate(password) > > link.wait() > > > > where command looks like "psql -h 127.0.0.1 -U postgres -W -f filename" > > and > > filename is the name of the file which contains a single SQL command > > which is "drop database mytempdb". > > > > the program works fine as long as a correct password is supplied, > > however, i have a problem if the password is incorrect since this > > exception is *not* handled within the scope of my program, instead, > > what is does is showing some error messages in the prompt. so my > > program, without knowing whether an errors has taken place or not, goes > > on to execute the next task. > > > > any clue? please let me know if you think the problem is not well > > addressed. =) > > > > thanks. have a nice one. > > Hi, damacy, > > Maybe I'm not understanding your code 100%, but have you tried catching > the return value of the psql process that you're launching? Just a > thought... > > --hiaips
hi, hiaips. thanks for your reply. are you talking about a try-except block? yes, i used that in case the psql process might throw an exception if there is any. but unfortunately, it does not do so. -- http://mail.python.org/mailman/listinfo/python-list