1

I want to connect from Matlab to Algo Financial Modeller results that are accessible through ODBC. However, I cannot find anyway to do it without database toolbox that I do not have.

I found this discussion: How to connect to Microsoft SQL Server 2008 (MSSQL) from Matlab?

But unfortunately there isn't presented any way that uses ODBC.

I would be grateful for any help in that matter.

Thanks in advance! Artur

1 Answers1

1

Yes, you can do without the database toolbox and use ODBC via ADO.

Example of something that works for me:

conn = actxserver('ADODB.Connection')
conn.Open('driver={MariaDB ODBC 3.0 Driver}; server=myserver; port=myport; dns=mydb; uid=user; pwd=password')
conn.Execute('use mydb')
r = conn.Execute('select * from my_table')
r.GetRows()

Some remarks:

  • Obviously, replace MariaDB ODBC 3.0 Driver with your own ODBC driver
  • Despite what some documentations say, server=myserver,myport does not work for me, port=myport does.
  • For some reason, despite having dns=mydb in the connection string, I still have to use mydb.
P-Gn
  • 23,115
  • 9
  • 87
  • 104
  • Hi, Thanks it worked, at least partially. I was able to connect to database and make a simple select * query. However I can't find a way to get more information about database (like what tables are in it, what are the tables structure etc). Do you know how to do something like sqlTables, sqlColumns from RODBC? – user7473630 Mar 15 '18 at 14:20
  • @Swistak I do not know of a generic way either. However you still can use your DB's specific queries for that, see e.g. this for tables: https://stackoverflow.com/a/175446/1735003 – P-Gn Mar 15 '18 at 15:37