python database location

Go To


Of course, assuming the program is running in the same directory with the database.

2012-04-03 19:56
by Garret


You do not need to provide an absolute path to open(), instead you can provide a relative path to the file you are opening from the current working directory.

You can use this to eliminate the need for your databasepath variable, as long as the script is run from the same directory as the database (or always has the same relative path to the database).

You may find the os.getcwd() function useful for determining what the working directory of your script is.

2012-04-03 20:02
by Andrew Clark