MySQL database location

Nick Arnett narnett at mccmedia.com
Mon Jun 17 10:44:11 EDT 2002


> -----Original Message-----
> From: python-list-admin at python.org
> [mailto:python-list-admin at python.org]On Behalf Of Pawel Lewicki
> Sent: Monday, June 17, 2002 2:42 AM
> To: python-list at python.org
> 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()

Nick






More information about the Python-list mailing list