Is it safe to implement a database connection on client side?

Is it safe to put a database connection (like MySQL) directly in the C++ and call queries through it? If it is better and recommended to put it server side, where should it be implemented?