I want to connect my MYSQL with anvil project. Is there any way to connect MySQL with anvil and how can we sync our external database in Anvil Project?. If we connect our anvil project with external database then can we use Data Tables Service with external MYSQL database. Currently I’m working on Business Plan. If there is any way then please let me know.
Yes, you can connect to MySQL with Anvil! Here are some resources:
Code snippets for connecting and querying MySQL:
A video guide to using an external database from Anvil (it uses Postgres rather than MySQL, but the architecture is all the same): https://anvil.works/blog/dashboard
And here is a more fleshed out example that uses an external DB (again, Postgres rather than MySQL, but the only difference is how you connect):
Regarding Data Tables, they are accessed using Anvil’s ORM, so the underlying database engine is not exposed to the user (but for completeness: it’s Postgres).
Do you have a specific requirement that MySQL satisfies or is it just that you have legacy data in a MySQL instance?
I want to use your Data Tables and other services Anvil provides with my external database. I also want to write some stored procedures in Postgres or MYSQL, Can I use these stored Procedures in my app?
If there is any way please let me Know.
With a dedicated system you can have full SQL access to the datatables (it’s essentially postgres) but you can’t use the Data Tables API with SQL databases, you’d need to use something like PyMySql or similar libraries.
The other paid for plans use shared resources and therefore SQL access is not possible.
The way I can handle the user in Data Tables of Anvil. Can I handle user as the same way in external database or not?? If it is possible then please let me know.
@david.wylie is correct: Anvil’s Data Tables is a database specially constructed to be easy to use from Python. The nice API (app_tables.<name>) and the visual table editor need that back-end to function.
If you want to work with any arbitrary external database, of course you can do that, with all the standard Python libraries – you’ve got the whole Python ecosystem! But if you want to use Data Tables, use Data Tables