How do I add a datasource inside a .cfm file to be executed in CommandBox?

I am new to CommandBox and I’m writing a script that adds database records to elasticsearch. I’m thinking that I will execute it from a .cfm file, but I quickly realized that CommandBox doesn’t run my application.cfc file, which sets up my datasources. How can I create a datasource inside my .cfm file, or is there a better way to get CommandBox to see my datasources?

How are you executing the .cfm? If you run it as
$> box myfile.cfm

The Application.cfc is run I believe. There is a possibility this differs based on Windows or Unix though if it does, it’s unintended.

You can also configure data sources via the cfapplication tag.



ColdBox Platform Evangelist
Ortus Solutions, Corp

ColdBox Platform:

I am on Windows and running it from box.exe using the execute command.

CommandBox:currentfolder>execute file=/build/elasticsearch/index-forum.cfm

I would suggest you use the application tag.