O'Reilly logo

D Cookbook by Adam D. Ruppe

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Accessing a SQL database

My Github repository at http://github.com/adamdruppe/arsd contains a database.d interface file and implementation files for MySQL, PostgreSQL, SQLite, and Microsoft SQL Server via ODBC. Here, we'll use them to perform some SQL queries.

Getting ready

Download database.d and a driver file (postgres.d for PostgreSQL, mysql.d for MySQL, sqlite.d for SQLite, or mssql.d for SQL Server) from my Github.

The drivers also require C libraries. The mysql.d file needs libmysqlclient, which comes with the MySQL server. The postgres.d file needs libpq, which comes with the PostgreSQL server. The sqlite.d file needs SQLite installed on the system.

Let's also create a test database to use from the program. In our example, we'll use MySQL, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required