This is a read-only archive of the Framer Community on Facebook.

What is Framer? Join the Community
Return to index
Doron Etzioni
Posted Mar 25 - Read on Facebook

I am new to Framer.JS and CoffeeScript, the last time I programmed was a while ago.
Can anyone refer me to a good example how to connect and query My SQL to load data into Framer.JS?

4 Comments

Juan J. Ramirez

That's a very broad question. First things first. CoffeeScript is just JavaScript but using what some people call a more "friendly and readable" syntax.

So, that being said, there's no way to run a query directly from JavaScript to a SQL database since JavaScript's nature (in this particular case) is to affect whatever is going on the browser.

The only way to do this is by setting up a hook/server side script that will run the query to the database and then will serve the response through an endpoint that you can hit using AJAX. The good part is that Ajax is pretty much baked-in every possible javascript library and getting that response is just one function invocation away.

So to recap:
1) No. You cannot directly query MySQL from the client-side (Chrome, Safari, FramerStudio)

2) You will need to have a server side script written in any server language like PHP, Node.js or Ruby to run that query and get the response.

3) You need to transform the response into something parseable by JavaScript like JSON and then serve the response through an endpoint that you can consume with an AJAX function.

...
As I said this is very broad and probably I just confused you more...but there are many good resources to learn this. I would start with something like the JS tutorial in W3Schools. That would definitely solve some doubts: http://www.w3schools.com/js/

Doron Etzioni

Thank you Juan J. Ramirez for your response, I installed Note.js, and run the "npm install mysql" under the [modules] directory of my project, so now I have [modules/mysql] directory]. In my Framer.js project, I put the first line to state mysql = require('mysql'), and I am getting the message [framer.generated.js]Error: Module mysql can't be found.

I know that I am missing something :-)

Juan J. Ramirez

Doron Etzioni That MySQL module is a Node.JS driver.... I don't think there's a way to run that from Framer since it needs an actual Node.JS instance to run.

Doron Etzioni

Thanks. I will keep trying

Read the entire post on Facebook