Skip to content

Instantly share code, notes, and snippets.

@Willshaw
Created March 31, 2017 23:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Willshaw/621a15502a3a3d6c1d66d6e46079988d to your computer and use it in GitHub Desktop.
Save Willshaw/621a15502a3a3d6c1d66d6e46079988d to your computer and use it in GitHub Desktop.
Simple Script for Local Development to setup coldfusion datasources
<cfscript>
writeOutput('starting db source installation...<br/ >');
function createDSN( name ) {
// Login is always required. This example uses two lines of code.
adminObj = createObject("component","cfide.adminapi.administrator");
adminObj.login("pete", "admin");
// Instantiate the data source object.
myObj = createObject("component","cfide.adminapi.datasource");
// Create a DSN.
myObj.setMYSQL5(
name="dsn#ARGUMENTS.name#",
host="127.0.0.1",
database=ARGUMENTS.name,
username="pete",
password="pete"
);
writeOutput('<br />created #ARGUMENTS.name# datasource');
}
arr_names = [
'books',
'authors'
];
for( name in arr_names ) {
createDSN( name );
}
writeOutput('<br />completed');
</cfscript>
@Willshaw
Copy link
Author

I need to check my chrome history to find the person who's code I modified to make this - credit must be given

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment