Skip to main content
Participating Frequently
January 18, 2023
Answered

Querying a MySQL database within the Lightroom SDK

  • January 18, 2023
  • 2 replies
  • 643 views

Hi, 

Is it possible to query a MySQL database within the Lightroom SDK using a library such as luasql or any other methods? I am looking to run basic SELECT queries on a database instead of reading in a CSV file as I'm currently doing.

Thanks,

 

Cooper

This topic has been closed for replies.
Correct answer johnrellis

The LR SDK doesn't allow the loading of Lua modules requiring non-Lua libraries.  So the only way to access an external database is by running a command-line program via LrTasks.execute() to generate a temp file and then reading the temp file into LR.

2 replies

Inspiring
October 7, 2023

A little bit late ...

 

As the others have stated it is not possible to query a database.

 

However it is very easy with Python (FastAPI) or Java (SpringBoot) for example to create a web service which queries the database.

 

From Lightroom you could call this web service with the LrHTTP GET or POST SDK modules and parse the reponse JSON.

There is a good implementation in Lua for parsing to and from JSON and lua tables.

Inspiring
January 18, 2023

What in particular are you looking to get from the db that you couldn't get from the Sdk alone? Maybe, for example,  using smart collections as queries and interrogating those?

Participating Frequently
January 18, 2023

The plugin is being used to search a customer database that is updated externally with client information so ideally want to be able to query directly from the db

johnrellis
johnrellisCorrect answer
Legend
January 18, 2023

The LR SDK doesn't allow the loading of Lua modules requiring non-Lua libraries.  So the only way to access an external database is by running a command-line program via LrTasks.execute() to generate a temp file and then reading the temp file into LR.