How to connect the database to ember

Hi! I am new to ember. I have lot of doubts on ember data like how to connect the database to ember and how to run the code with database. is it necessary to run any back end servers with ember server for working with back end.

Hi @Santhoshi, hopefully I can help clear things up for you. Ember is a front-end framework only, and the ember serve command is meant only for development purposes. AFAIK any modern front-end framework will work like this, meaning it will require some sort of API or backend layer. Ember is not a framework intended for developing server-side code. It is, however, highly customizable so you can fit it onto whatever backend you need.

A production ember app will essentially require two servers, or at least a server that serves two different things:

  1. the Ember app itself (an html file, some js, css files and assets)
  2. the API endpoints that the Ember app uses for data

So the ‘ember serve’ command is meant only to fulfill item 1 above, and only for development purposes. To connect a database you’d either want to write your own server API or use something like Firebase or maybe PouchDB (@broerse could probably tell you more about that).

When you actually deploy a production ember app you would typically deploy to a static file service like Amazon S3 or use any other standard webserver with configuration for service a webapp, but again you would never use ember serve in production. It is merely a convenience for serving the webapp locally during development.

1 Like

@dknutsen Thanks! @Santhoshi Yes will let you talk to an in browser PouchDB server. This server can be synced with a CouchDB server like IBM cloudant or your own CouchDB. For testing you can just run PouchDB without a server. The Ember App can be deployed to the CouchDB database so you don’t need a web server. is deployed to a CouchDB server this way. (We are in the process of switching from to so it can break in the next week)

Source for Bloggr Example

@dknutsen thank you for reply.I got some idea on database but i need to know api server.Actually i working on mysql database.Is there any format for writing the api path to connect the database.

Hi @Santhoshi, in order to manage the data you want to save you’ll need to use a backend framework like rails, phoenix or nodejs. These will let you save the information from the ember app to the database.

GoRails have a series which should walk you through this process. You can find it here.

Hi @James-Byrne, I already installed nodejs framework but i don’t know how to connect the database.

Ahh sorry @Santhoshi, in that case heres a tutorial on connecting a node app to a mysql db.

@James-Byrne Thanks, can you provide tutorial on simple user login system using ember-php-my sql with REST adapters.

@Santhoshi if you want to work with ember without having to worry about the whole server-side end of things, look into ember-cli-mirage

Hi!.. Im working on my ember training project where it is a login form… I need to use java servelts to get the input text field from the login form(username,password)and store it in mysql database. How to get the input values to servlets program

Hello and welcome :wave:t2: Generally with login forms you will need to post your data (using fetch or another Ajax library) to an endpoint that your Java pages expose. Your Java code will then save the data to your MySQL database. Does that help?