#`bal persist` vs `ballerinax/mssql`

1 messages · Page 1 of 1 (latest)

opaque rose
#

Hi Team,

I am implementing a REST API in ballerina and have decided to use mssql db.
What will be the difference between using bal persist and ballerinax/mssql?
Which is recommended?

fiery nacelle
#

Hi @opaque rose,

The main difference between the two is that with ballerinax/mssql you would have to write your own SQL queries while bal persist will handle that for you. While this would make performing simple CRUD operations easier with bal persist, at the same time if you need to execute complex queries (multiple JOINS, comparisons, procedures etc.), you would need to go with ballerinax/mssql as the persist module does not support complex queries yet (this is a feature we are working on at the moment). In terms of performance, ballerinax/mssql will be marginally better than bal persist as long as you write optimized queries.

So the implementation you should go with will depend on your requirement.

If your API requires very complex operations, I would suggest for you to go with ballerinax/mssql, but if it's performing simple CRUD operations, I would suggest to go with bal persist.

#

bal persist does offer a few other features as well that you can consider.

  • It will handle the creation of the database and tables for you. You would only need to define your data model; and the table generations SQL scripts will be generated for you.
  • If you decide to change your database in the future (e.g. using MySQL instead), there will be minimal code changes required.