database location in python?

Posted on
Fri Apr 03, 2020 12:38 pm
dduff617 offline
Posts: 659
Joined: Jul 05, 2006
Location: Massachusetts, USA

database location in python?

I have few testing/diagnostic scripts that reach into the Indigo log database and run some queries against it.

I was curious if there exists any way to reference the current database file other than by a specific hardcoded pathname in the script? I find that my scripts break with each point release of Indigo.

Or at least is the there a recommended way in a python script I can reference the "root" Indigo directory (/Library/Application\ Support/Perceptive\ Automation/Indigo\ <major version>.<minor version>/)?

Posted on
Fri Apr 03, 2020 2:16 pm
matt (support) offline
Site Admin
User avatar
Posts: 21416
Joined: Jan 27, 2003
Location: Texas

Re: database location in python?

I believe you want:

indigo.server.getDbFilePath()

Also available:

indigo.server.getInstallFolderPath()

Lastly, check out this wiki page.

Image

Posted on
Fri Apr 03, 2020 2:25 pm
dduff617 offline
Posts: 659
Joined: Jul 05, 2006
Location: Massachusetts, USA

Re: database location in python?

Thanks, Matt - that's very useful.

I should have been clearer but i was asking in the context of a discussion of SQL logger, so I was actually referring to the db file used by SQL logger (so I can write python code to query the database) - in my case using sqlite3.

I see that database you are referring to is the main Indigo database file. Still, I can get what I need using:
Code: Select all
dbfile = indigo.server.getInstallFolderPath() + '/Logs/indigo_history.sqlite'

Posted on
Fri Apr 03, 2020 2:36 pm
matt (support) offline
Site Admin
User avatar
Posts: 21416
Joined: Jan 27, 2003
Location: Texas

Re: database location in python?

Yeah, I'd recommend getting the root install path and appending on the path to the default SQL file like that. The filename might be different if the user overrides the default, but for personal use your technique will be robust and not break with future Indigo upgrades.

Image

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests