Hi,
Just wanted to share a short example demonstrating how to connect NinjaTrader7 --> MySQL --> R(2.12). The example is just trivial, pulling a vector of closing values from NT7 into R, but it demonstrates the power.
Assumes NT7, MySQL, MySQL Connector/Net, .Net Framework and R are installed.
I used a Windows 7 (64) base. I used NT7(32) and R(32).
Assumes “Complete” install option for MySQL (this includes the client header and library files).
I had to uninstall and then reinstall .Net Framework, MySQL Connector and NT7 for this to work.
NT7 was very fussy about referencing the assemblies to get the MySQL connection.
I used the following reference paths:
C:\Windows\Microsoft.NET\assembly\GAC_MSIL\MySql.Data\v4.0_6.3.6.0__c5687fc88969c44d\MySql.Data.dll
C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Data.dll
This tutorial is a huge help for setting up RMySQL:
RMySQL needs Rtools212.exe .
Download and Install (for your version of R):
From:
Create the MySQL database:
shell> mysql -u root -p
>CREATE DATABASE testBlob;
>use testBlob;
>CREATE TABLE closes (
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
close MEDIUMBLOB);
>DESCRIBE closes;
Configure R:
Navigate to:
C:\Program Files\R\R-2.12.0\etc
In Renviron.site type:
MYSQL_HOME=C:\\PROGRA~2\\MySQL\\MYSQLS~1.1
I had a hard time finding the short name for the path.
Eventually I used the small vb script found here:
Restart R.
Check that the MYSQL_HOME environment variable is set, at the R prompt type:
Sys.getenv('MYSQL_HOME')
This returns:
MySQL_HOME "C:\\PROGRA~2\\MySQL\\MYSQLS~1.1"
Then in R:
install.packages('RMySQL',type='source')
R Script for connecting to MySQL db:
library(RMySQL)