Create a database connection conn using the ODBC driver. This
code assumes that 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.
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.
dbds =
DatabaseDatastore with properties:
Connection: [1×1 database.odbc.connection]
Query: 'SELECT * FROM productTable'
VariableNames: {1×5 cell}
ReadSize: 10000datastore executes the SQL query sqlquery and
creates a cursor object with the resulting data.
dbds contains these properties:
Display the database connection property Connection.
ans =
connection with properties:
DataSource: 'MySQLdb'
UserName: 'username'
Message: ''
Type: 'ODBC Connection Object'
Database Properties:
AutoCommit: 'on'
ReadOnly: 'off'
LoginTimeout: 0
MaxDatabaseConnections: 0
Catalog and Schema Information:
DefaultCatalog: 'toy_store'
Catalogs: {'information_schema', 'toy_store'}
Schemas: {}
Database and Driver Information:
DatabaseProductName: 'MySQL'
DatabaseProductVersion: '5.5.46-0+deb7u1'
DriverName: 'myodbc5a.dll'
DriverVersion: '05.03.0004'The Message property is blank when the database connection is
successful.
Close the DatabaseDatastore and database
connection.