MySQL database location

Nick Arnett narnett at
Mon Jun 17 16:44:11 CEST 2002

> -----Original Message-----
> From: python-list-admin at
> [mailto:python-list-admin at]On Behalf Of Pawel Lewicki
> Sent: Monday, June 17, 2002 2:42 AM
> To: python-list at
> Subject: MySQL database location
> Hi,
> Is is possible to get the physical path to the MySQL database file using
> MySQLdb or any other pythonous way?

Yes.  Execute "SHOW VARIABLES" and you'll get a list of name-value pairs for
all of MySQL's current variables.  The data directory is "datadir".

For example, to print them:

	self.dbh.execute("SHOW VARIABLES")
	print self.dbh.fetchall()


More information about the Python-list mailing list