Reading and writing CSV data using CONNECT
CSV (comma separated values) is a very common data-interchange format. MariaDB can easily import CSV formatted files using the LOAD DATA INFILE
command, and there is a CSV storage engine that stores data in the CSV format. However, neither of these handles cases where we need to be capable of querying CSV files that are updated outside of MariaDB and CSV files that we don't have to import before we can query them. The CONNECT storage engine's CSV
data type allows us to do this easily.
Getting ready
We need to have some CSV data to work with for this recipe. We'll use data from the ISFDB
database for this. To start with, perform the following steps:
Import the
ISFDB
database as described in the Importing the data exported by mysqldump recipe from Chapter 2, Diving Deep into MariaDB.Install and enable the CONNECT storage engine as described in the Installing the CONNECT storage engine recipe at the beginning of this chapter.
Launch the
mysql
command...