0

Is it possible to connect to a MySQL database directly from an Ionic application without an integration/api layer?

All the answers I found online suggest to create API in php or nodejs, but I would like to develop a sql client and the whole point of the application is to be able to make queries directly from the client device.

I cannot use the node mysql library from client side.

I am using Ionic 6 React.

1
  • 1
    you can't direct access mysql from device... nodejs can access it because it acts as a server but as a native/hybrid platform, it can't direct access mysql... the only possible solution is to using api's.. Commented Jun 25, 2022 at 8:03

1 Answer 1

1

No, as noted by Mostafa Harb, you cannot directly access a MySQL database in the cloud from a device. You'll need to use some kind of API.

The basic flow:

  • Ionic app authenticates to the API if necessary.
  • Ionic app uses Axios or Fetch to use the API to query the cloud database.
  • The API returns the response in a format the Ionic app understands.

The good thing about Ionic is that it is mostly framework-agnostic, so you can use any API you like.

Personally, I use Drupal, which is a PHP-based CMS that has support for providing access to Ionic via REST, JSON:API, or GraphQL (or a mix of the three).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.