Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying D Cookbook
  • Table Of Contents Toc
D Cookbook

D Cookbook

By : Adam Ruppe
5 (9)
close
close
D Cookbook

D Cookbook

5 (9)
By: Adam Ruppe

Overview of this book

Table of Contents (21 chapters)
close
close
D Cookbook
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
2
Index

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, so create a MySQL database, user, and data table. The following are the commands you can run in the MySQL console:

create database demonstration;
use demonstration
grant all privileges on demonstration.* to 'demo_user'@'localhost' identified by 'test...
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
D Cookbook
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon