Sandro Mirijanashvili
Sandro Mirijanashvili

Reputation: 59

mysqldump: not found - exporting database in python

I am trying to export a database using this code

os.system('mysqldump -u %s -p%s %s > %s' % (user, password, database, filepath))

When I run the program for the first time it exports my database and everything works fine just it gives me this error.

sh: 1: mysqldump: not found

Next run (when database is already exported) it works without any error. how can I fix this ?

Upvotes: 1

Views: 92

Answers (1)

Loïc
Loïc

Reputation: 11943

You could locate mysqldump full path and use that.

In your terminal :

whereis mysqldump

You'll get its full path, which you can then use inside your python script.

Upvotes: 1

Related Questions