Connect to mysql from iOS and/or Android

Hi!

Unfortunately, i noticed yesterday, on my very first iOS app, that Xojo does not have support to connect to mySQL… nor Android…

OMG!

Is there any reason for this? It’s planned to have someday?

Yesterday i also started to search another IDE… because it’s crucial, for me, to connect to an external DB…

Alex

If you have MBS, its SQLDatabaseMBS can connect from iOS to MSSQL (I know this is not what you’re asking for). MBS do have the mysql-8.4.4-macos15-arm64 drivers for macOS, but I’m not sure if this works for iOS. PostgreSQL is not available for iOS through SQLDatabaseMBS.

Christian has mentioned he is open for people to pay him to bring the C++ MySQL and PostgreSQL drivers to iOS (I’m not sure of the time/cost). I haven’t tried SQLDatabaseMBS from Android, but I don’t think Christian can provide any SQL drivers for Android until he gets a Xojo SDK kit for Android (not coming according to Xojo) or possibly the new Libraries feature for Xojo, which Xojo have said includes Android.

My understanding is, that literally nobody should consider direct access to a sql database from a mobile device, which connects thru the open internet. Because of security concerns and open ports needed. Middleware on a server is used for this, via REST for example.

4 Likes

That’s an industry standard. A mobile app should contact external DBs using some sort of protected API, reading/writing what they need without keeping an active connection.

https://www.sapphiresolutions.net/blog/mobile-app-development-role-of-databases-in-the-process#:~:text=Development%20of%20mobile%20applications%20requires%20database%20interaction,it%20easier%20to%20get%20and%20store%20data.

4 Likes

The preferred design to connect a mobile app to a database service such as MySQL is to do so via a web service. The service connects to the DB and the mobile app connects to the web service. This would typically be a REST design and is far more reliable, secure and better for mobile device resources.

You can learn more about web services and find a video about how to build a database web service in the docs: Accessing Web Services

5 Likes

react/next.js running on node.js? it have server side actions with direct access.
you could make a entire web app based on java script / type script divided into server and client side. (Editor WebStorm or VS Code) similar to xojo web app then.

the database itself could also output json

SELECT json_object('name', name, 'phone', phone)
FROM person;

I have been making Xojo iOS apps that do SELECT, UPDATE, INSERT, DELETE queries with a MySQL database for the past 9 years.

The middleware used is GitHub - alixaxel/ArrestDB: RESTful PHP API for SQLite, MySQL and PostgreSQL Databases

It is basically plug & play and can even run on a serverless App platform such as DigitalOcean.

Mobile devices don’t have a stable connection, they should never connect directly to any network based database as said by Rick and Paul.

I hope not as it would be useless.

9 Likes

well… i have a question for all…

what’s the difference between connect to a mysql database from my home to my server, using my XOJO DESKTOP app, or my XOJO iOS app?…

both applications are compiled… both applications will connect thru wi-fi / internet…

so… what’s the real deal?

Alexandre

I’m not a world class expert in Xojo, but I’ve connected a few databases in my time. No mobile database client I know of can create a direct connection to an external database server like MySQL. You can do this by accessing a web page which has a MySQL back end, or create/adopt a web service. Client connections like ODBC and ADO won’t cut it. I suppose creating a web view in your IOS app would be the most direct way.

As an essentially lazy person, I would opt for doing a web page and using Mobile Safari. But if you’re wedded to the IOS app premise, embed a web view.

If you actually want to do work (unlike myself), try this:

https://www.youtube.com/results?search_query=xojo+web+services

peace

fritz

1 Like

Phones are built for intermittent cellular connections and protocols like HTTP were tailor made for systems like that. Desktops with an OS that can handle gigabit ethernet and ADO and such are simply more robust and offer you more options than you can squeeze into a phone. Client server on a desktop is predicated on the assumption of a continual connection with constant two way communication. That can’t be assumed on a phone out in the wild, whether you’re using wifi or cellular.

1 Like

It was answered before… 2 times.

LAN ≠ Internet

Internet is a wild place. There are hackers actively scanning vulnerabilities there as a DB door exposed, and will try to gain access to it. Many times they will.
If you implement a good middleware, or it will get listed as an “unknown” port by the scanner, or some sort of HTTP whatever they maybe are not interested in trying to explore.

i think the phone network is not the issue.
it is more the concept and mind set of apple or google if they will support all this databases (via driver software)
or people need their cloud services.
object serialization is more welcome than this relational database from my point of view.

about network connection to a database we have digital certificate, a hacker will not have success without.

Keep in mind that there are always unintended vulnerabilities and exposing a database directly to the internet is a great invitation for someone to try and find one. Unless you’ll be keeping up and installing patches for every zero day hack that comes out, it’s still best to protect a database with an API. not to mention that it also allows you to do things like throttling if someone decides to abuse the server in some way.

i also don’t think the problem is the network…

Let’s say, i did an Desktop App… Running on my Macboook… connected thru usb 5G chip…

Or, i did an iOS app, connected on my home’s wi-fi, thru VPN, to my mySQL server.

What’s more secure?

But ok.

To use API, we need to send the user/password to server, so what’s the difference using desktop app connecting to mysql or ios app connecting to API?

So, let’s be simple… why not iOS + VPN + mySQL?

None, it is the same principle.

Just the “recomendations” and “standards“.

Any mobile app can do it, JDBC on android for example.

It is not the recommended way and not many users want the feature so dont hold your breath.