How to connect to a database? How to read or write data?

How to make a website with dynamic content? We need to store the content somewhere. And a good, searchable storage is a database. Almost every webservice needs a database. But how do connect to the database? And how do we read and write the data?
1 answer

This one is the BEST answer!

The answer is: it depends.
It depends on the programming language you are using and partially on the database you are using.
Most of the databases are services running on a web service. We can communicate with them using a special protocol, while we know the address and the port of the server where it runs. There are also databases stored in files, where we specify the target file.
Most of the programming lanugages and frameworks provide a "Connector" for databases, which allows us to communicate with the database. Of course you need to check if your programming language has a driver for the database type you want to connect to. Some frameworks or programming languaes also offer a higher level control structures called object-relational mapping, where the user can easily read or write some objects defined in the project.