Delphi existing application connect to cloud - mysql

I have my application in Delphi with MySQL as a database. This is a Desktop application with local Database connected using ADO components.
I have another web application done in PHP and MYSQL.
I want to merge both databases and connect the Delphi application to the cloud MySQL database.
Do I need to put all my logic in PHP scripts and access them from Delphi?
How Delphi to cloud connection can be established?

You can use FireDAC to connect to a database located in the cloud, as soon as your provider allows that connectivity.
But exposing you database to the internet is not the best secure architecture. As you suggest yourself with naming it, a much better architecture is REST. The idea is to write server side software - could be PHP - to accept REST requests from a client, execute it (access the database) and send a reply to the client.
Today's, the REST requests are frequently using JSON to pass requests and receive replies. JSON is supported by Delphi. In short, this is an ASCII representation for object properties.
If accessing the database directly is what you really want, look at this video by Stephen Ball showing how to access an MS-SQL database on Azure cloud. This would be pretty well the same with mySQL.

Related

How to use relational DB with online/offline replica with Electron-Node?

I am just starting to use Electron and I have a question about databases. Due to the kind of App I am developing I need a relational DB.
The idea is the user will open the App, if there is connection it would store the data both locally and remotely. If the App is offline it will store the data locally and whenever is online again it will send that data to the remote server. Basically it will be thee same database (local and remote) but it can work offline if necessary.
I am lost on which database will be better for this. As I said I am using MySQL right now and I know you can use MySQL with nodejs so I might give it a try. Also, I am used to use MySQL within a backend language such as PHP, how would you do it in Electron?
Thanks for your time guys!

How to connect to a client server database in PhoneGap?

I have been searching this topic for a long time but I haven't found the answer I wanted. I want to connect to a MySQL database on a client-server and insert some info on a table using an app I made using PhoneGap. I found things like that but didn't seem to do what I want them to do: http://docs.phonegap.com/en/2.7.0/cordova_storage_storage.md.html#SQLTransaction
This documentation page doesn't make any sense to me.
Does anyone know how can I solve my problem? Thanks in advance.
You normally don't access database on your server dirrectly from the app in your phone.
The doc you saw about SQLTransaction is about writing data to the SQLite database that is inside your device, not to write to a remote database.
What is usually done to communicate with a remote database is we perform http requests to a web server (php, java, .net, ruby, perl or whatever you like) and that server will communicate with the database server.
If you really want to communicate with your mysql server from your phonegap app, you would have to include native mysql libraries in your project and write native code to communicate with the mysql server. And I don't think it woule work very well through a data connection...

How to write to a remote DB from an android app

We have an android app that currently sends data to a php script which writes to a mysql DB on the same server. We are thinking of using a scalable DB server e.g. FathomDB (which is just based on amazon RDS & rackspace) so that we can handle load increases easily.
The question is how does our android app write to these remote DBs? Do they have some kind of rest API, or allow you to have a php script similar to the one we have in place at the moment?
I'd say most of services like these have a connector running on the web, like the one you are using. But some of the services you mention (for example amazon rds) have a native mysql connection. So you can connect using mysql to the server and run queries like you currently do in php. You can use ACL to ensure security in your application :)

How to integrate database into software

I am practicing writing an app which use MySQL to manipulating data.
My concern is if my client machine doesn't have have MySQL pre-installed, it's not be able to run my app, is it?. So is there anyway to embed the database server right into the app, or to run the app without the data server. I wonder how all the softwares out there manipulates data. It's not like we need to install some kind of database server before install the app.
MySQL is a client/server database engine, which means that you must install the client and server separately from each, and they communicate over some kind of network protocol.
If you want to deploy a stand-alone application, you are probably better off using a library like SQLite, which gives you as much of the functionality of a SQL database as you are likely to need in such an app, but instead operates on local files and doesn't require installation of a separate server.
You can embed MySQL in your application, see MySQL as an Embedded Database for details.
Your application could work with the remote database, when configuring database connection you should set your DB server IP address(host), port and login credentials. so in order to write application which is dealing with data manipulation, you need to connect to any database instant.
If you are working on client-server application, MySQL database may be accessed either by means of MySQL (this solution may be suitable for internal networks), or through some database-side service, which can provide some API and which can be accessed from client via some application-level protocol (for example, XML-RPC).
If you are working on client application, there are other database solution, which can be used in stand-alone software: SQLite, Derby. As an alternative to database approach, you may consider storing data in XML / YAML format.
I suggest to wrap db layer in you application witch simple interface provided for all operations performed on the database. In this way, you will not have to go into the details of the atomic operations on the database and through unified interface, you can create several different classes which will be responsible for access to different databases in the same way (the same interface). These classes should realize the interface and implement all necessary methods inside (for example ADO). Now your db layer can be visible in all program it the same way. Wrapped class can realize singleton desing pattern and can be used as one instance enywhere in your application. Universal class design (interface) gives you many benefits such as the possibility of substitution on another layer if necessary (switch to a totally different db).

how to connect mysql server on external server in j2me application

I have a hosting account at godaddy ruinning Linux. Is has MySQL. I am creating a J2ME application that runs on android and I was wondering if there is any simpler way to connect from j2me application to my MySQL server?
Is it required to install anything at my server? which I cannot do because of the shared account. Any way to just open the connection, update some data in the MySQL from j2me application?
It is quite simple. You just need to do HTTP application/x-url-form-encoded request on the midlet and set request property to HTTP.POST. Then stream form data as bytes. Receive those post variable using a server side language (i used PHP) like $_POST['var'] and in that server script write MySQL query like insert into .. VALUES.. etc.
I don't know if any DB drivers exist for J2ME. If you can't find them just make layer on the server and implement your own protocol for retrieving data via http or sockets