Connect to an SQLite database and verify the database connection. Then, import data from the database into MATLAB®. Determine the highest unit cost among the retrieved products in the table. Close the database connection.
Create the SQLite connection conn to the existing SQLite database file tutorial.db. The database file contains the table productTable. The SQLite connection is an sqlite object.
dbfile = "tutorial.db";
conn = sqlite(dbfile);
Determine if the database connection is open. The isopen function returns the numeric scalar 1, which means the database connection is open.
i = isopen(conn)
i = logical
1
Select all the data from productTable and sort it by the product number. data is a table containing the imported data that results from executing the SQL SELECT statement.
sqlquery = "SELECT * FROM productTable ORDER BY productNumber";
data = fetch(conn,sqlquery);
Determine if the database connection is closed. The isopen function returns the numeric scalar 0, which means the database connection is closed. If the database connection is invalid, the isopen function returns the same result.
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window.
Web browsers do not support MATLAB commands.
Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: United States.
Sie können auch eine Website aus der folgenden Liste auswählen:
So erhalten Sie die bestmögliche Leistung auf der Website
Wählen Sie für die bestmögliche Website-Leistung die Website für China (auf Chinesisch oder Englisch). Andere landesspezifische Websites von MathWorks sind für Besuche von Ihrem Standort aus nicht optimiert.