Note that there are some explanatory texts on larger screens.

plurals
  1. PORenaming a Dataset using a list
    primarykey
    data
    text
    <p>I'm new at programming, and I've been banging my head trying to figure this out for work. </p> <p>I am trying to pull roughly 300 mysql tables into Matlab into my workspace.</p> <p>I have attached the following code, which is designed to pull one table (I plan to loop this code though the 300 mysql tables when it is working). </p> <p>The code successfully works to import single table into the workspace as a new dataset.</p> <p>My problem arise when I try to rename this new dataset with the name of the original mysql table.</p> <p><em>Please see code below for this part where I screw up (%Assign data to output variable)</em></p> <p>I have a list of all the 300 tables names, and I plan to store them in a list called 'name'... Hence, name(1)... is this the right approach? </p> <p>For example, the original mysql table was called 'options_20020208'.</p> <p>After I run the script, I need the new dataset that Matlab imports to be called 'options_20020208' as well. </p> <p>Any ideas here? </p> <pre><code>%Define Query name = 'options_20020208' %Set preferences with setdbprefs. setdbprefs('DataReturnFormat', 'dataset'); setdbprefs('NullNumberRead', 'NaN'); setdbprefs('NullStringRead', 'null'); %Make connection to database. conn = database('', 'root', 'password', 'Vendor', 'MYSQL', 'Server', 'localhost', 'PortNumber', 3306); %Read data from database. curs = exec(conn, [['SELECT ',name,'.UnderlyingSymbol , ']... , [name,'.UnderlyingPrice , ']... , [name,'.Expiration , ']... , ['FROM ','PriceMatrix.',name,' ']... ]); curs = fetch(curs); close(curs); %Assign data to output variable name(1) = curs.Data; %Close database connection. close(conn); %Clear variables clear curs conn </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload