Main Content

Interact with Data in SQLite Database UsingMATLABInterface to SQLite

To analyze your data using SQL in MATLAB®without access to any 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. For details, seeMATLAB Interface to SQLite. The SQLite connection is different from a database connection created using a JDBC driver. For background information about SQLite databases, see theSQLite Home Page.

MATLABInterface to SQLite Advantages

With the MATLAB interface to SQLite, you can start working with data immediately after installing the Database Toolbox by creating an SQLite database file. No installation or administration of software or drivers is required. You can share data using SQLite database files. Also, you can deploy a standalone database application without additional installation or configuration on target machines. The MATLAB interface to SQLite supports Windows®, Linux®, andMac.

Command Line Workflow forMATLABInterface to SQLite

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.

  1. Create an SQLite database file by usingsqlite. The SQLite database file has a.dbextension. Thesqliteobject signifies an SQLite database connection.

  2. Create tables in the SQLite database file by usingexecute.

  3. Export your data into the SQLite database file by usingsqlwrite.

  4. Import data into MATLAB by usingsqlreadorfetch.

  5. Perform data analysis in MATLAB.

  6. Export results into the SQLite database file by usingsqlwrite.

  7. Close the SQLite connection by usingclose.

  8. 分享SQLite database file with others.

  9. Create a standalone SQLite database application and deploy it.

Database Explorer App Workflow forMATLABInterface to SQLite

If you have an existing SQLite database file, you can use theDatabase Explorerapp to create an SQLite connection. These steps show how to create the connection.

  1. Open the Database Explorer app.

  2. In theConnectionssection, clickConnect.

  3. SelectOpen SQLite File.

    List of data sources and SQLite file for database connection

  4. Navigate to the folder where your SQLite database file exists and select the file. ClickOK.

  5. Database Explorer creates an SQLite connection. TheDatabase Browserpane displays the available tables in the database.

在您创建SQLite连接,你可以e Database Explorer to explore the data in the SQLite database and import the data into MATLAB. For details, see these topics:

SQLite JDBC Connection Differences

The following table describes the differences between using the MATLAB interface to SQLite and using the JDBC driver to connect to an SQLite database.

Item

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 operations

Yes

Yes

Database Explorer

Yes

Yes

Database metadata

No

Yes

Complex functionality

No

Yes

MATLABInterface to SQLite Limitations

The limitations of using the MATLAB interface to SQLite are:

  • NULLvalues are not supported as the first value in any column.

  • Database import options are not supported.

Related Topics

External Websites