User`s guide
datastore
7-63
datastore
Create datastore to access collection of data in a database
This datastore function creates a DatabaseDatastore object. You can use this object
to read large volumes of data in a relational database.
A DatabaseDatastore is one of the available datastore types. You can create other
types of datastores using the MATLAB function datastore. After creating any
datastore, you can analyze data by writing custom functions to run MapReduce using the
mapreduce function. For details, see “Getting Started with MapReduce”.
Syntax
dbds = datastore(conn,sqlquery)
Description
dbds = datastore(conn,sqlquery) creates a DatabaseDatastore object dbds
using the database connection conn. This datastore contains query results from the
executed SQL query sqlquery.
Examples
Create a DatabaseDatastore
Create a database connection conn using the native ODBC interface. This code assumes
you are connecting to a MySQL database with the data source named MySQL, user name
username, and password pwd. MySQL contains the table named productTable with 15
product records.
conn = database.ODBCConnection('MySQL','username','pwd');
Create a DatabaseDatastore object dbds using the database connection conn and
SQL query sqlquery. This SQL query retrieves all products from the product table
productTable.