The database server will receive queries through the network connection and return the results through the same connection. In order for a program to query the database, it must have a connection to the database. The most convenient way for programmers who will use the library to manage connections is for each part of a program that needs a connection to create its own connection. The more connections there are to a database, the longer it takes to create new connections. Each database connection uses a network connection.
Some platforms limit the number of network connections that they allow.
Your design for the library will have to reconcile these conflicting forces. The need to provide a convenient API for programmers pulls your design in one direction. The high expense of creating database connection objects and a possible limit to the number of database connections that can exist at one time pulls your design in another direction. One way to reconcile these forces is to have the library manage database connections on behalf of the application that uses the library. The strategy the library will use to manage database connections will be based on the premise that a program's database connections are interchangeable.