To analyze your data using SQL in MATLAB® without access to a database or driver, use the MATLAB interface to SQLite. After installing Database Toolbox™, you can use the MATLAB interface to SQLite to move data between MATLAB and an SQLite database file. The SQLite connection is different from a database connection created using a JDBC driver. For background information about SQLite databases, see SQLite Home Page. To use all the Database Toolbox functionality, install the SQLite JDBC driver and connect to your SQLite database file using a URL string. For details, see Configuring Driver and Data Source.
The advantages of using the MATLAB interface to SQLite are:
Start working with data immediately after installing the Database Toolbox by creating an SQLite database file.
No installation or administration of software or drivers required.
Share data using SQLite database files.
Support for Windows®, Linux®, and Mac.
The following table describes the differences between the MATLAB interface to SQLite and connecting to an SQLite database using the JDBC driver.
SQLite Connection Using the MATLAB Interface to SQLite | SQLite Database Connection Using a JDBC Driver | |
---|---|---|
Driver installation | Not required | Required |
Database installation | Not required | Required |
Database administration | Not required | Required |
Database connection function | sqlite | database |
Import data | Yes | Yes |
Export data | Yes | Yes |
Database Explorer | No | Yes |
Run stored procedures | No | Yes |
Database metadata | No | Yes |
Other complex database operations and functionality | No | Yes |
To connect to a database quickly and import data, use the MATLAB interface to SQLite. These steps provide a high-level workflow for using the MATLAB interface to SQLite.
Create an SQLite database file using sqlite
. The SQLite database
file has a .db
extension.
Create tables in the SQLite database file using exec
.
Export your data into the SQLite database file using insert
.
Import data into MATLAB using fetch
.
Perform data analysis in MATLAB.
Export results into the SQLite database file using
insert
.
Close the SQLite connection using close
.
Share the SQLite database file with others.
The limitations of using the MATLAB interface to SQLite are:
Only DOUBLE
, INT64
, and
CHAR
data types are supported.
NULL
values in columns are not supported.
Database Explorer is not supported. Use the command line.
close
| exec
| fetch
| insert
| sqlite