Video: Accessing any Delphi compatible database through a REST API using SQL
I have expressed this before, but Delphi is and will hopefully always be the number one programming language for database-driven applications. The architecture that has been there since Delphi 1 is still standing strong. Of course, there has been need for change to the database drivers, due to technological advances. However, at the inner core the classes TDataset and TDataSource as still standing strong.
Web Applications, multi-platform development, and mobile platforms make it necessary to introduce a layer in between the database and the application. Web Services producing JSON formatted data following the REST principle have become the pseudo-standard. As a side-note, REST is still not a standard and only a principle.
SQL is still the database query language that developers feel most comfortable with. The Web Service Layer introduces an insurmountable challenge for many. Thus, there are more frameworks than sand at the beach to facilitate the process. TMS Software offers a straightforward, affordable solution if you need to build a Web Service API with JSON called XData. If you look for performance, no need for JSON and a quick way to migrate your database project use RemoteDB from TMS instead.
For the case that you need a REST API with JSON support, I recorded the following video. It teaches you how to hook up any database supported by Delphi to the web service. You will then be able to offer any SQL query as a result for the web service. Further, you can even use parameters.
Stay tuned for more video content about RemoteDB. An even quicker and more efficient solution to provide abstract database support to your client applications. Abstract database support means in this case that the client is unaware which database you use and also will not need the database driver technology to access the data.
The video will explain step-by-step how to:
- Create a web service with XData
- Add the database connection to a FireDAC database
- Add the database query
- Add a service for the SQL queries
- Write a VCL Forms client that displays the data
Be aware of the fact that the client will not need any XData-specific components.
The VCL client actually does not need to create the TStream instance as the XData framework does that. Thus, the correct client-side code is this:
LStream := LService.GetSchools as TMemoryStream
There is no need to do anything else with LStream.