Fetch (write) data from (to) MySql workbench

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

elias41
Posts: 25
Joined: Mon Jun 10, 2013 1:20 am

Fetch (write) data from (to) MySql workbench

Postby elias41 » Mon Feb 02, 2015 8:39 am

Hi,

is there a way to write an EViews program which would enable to fetch from and write to a MySql workbench database?

EViews Steve
EViews Developer
Posts: 844
Joined: Tue Sep 16, 2008 3:00 pm
Location: Irvine, CA

Re: Fetch (write) data from (to) MySql workbench

Postby EViews Steve » Mon Feb 02, 2015 8:57 am

EViews can read from and write to MySQL using their ODBC driver.

You'll have to install the MySQL ODBC driver:
http://dev.mysql.com/downloads/connector/odbc/

Then create an ODBC DSN on your machine:
http://forums.eviews.com/viewtopic.php? ... mysql#p132

Then to read in data:
http://forums.eviews.com/viewtopic.php?f=3&t=28

Or write data:
http://forums.eviews.com/viewtopic.php?f=3&t=29

Steve

EViews Steve
EViews Developer
Posts: 844
Joined: Tue Sep 16, 2008 3:00 pm
Location: Irvine, CA

Re: Fetch (write) data from (to) MySql workbench

Postby EViews Steve » Mon Feb 02, 2015 8:58 am

Another related post regarding MySQL directly:
http://forums.eviews.com/viewtopic.php? ... sql#p17568

elias41
Posts: 25
Joined: Mon Jun 10, 2013 1:20 am

Re: Fetch (write) data from (to) MySql workbench

Postby elias41 » Mon Feb 02, 2015 9:55 am

How would the syntax look like between wfopen(type=odbc) and "select ..." in case I would like to connect to a server with a database requiring user id and password?

EViews Steve
EViews Developer
Posts: 844
Joined: Tue Sep 16, 2008 3:00 pm
Location: Irvine, CA

Re: Fetch (write) data from (to) MySql workbench

Postby EViews Steve » Mon Feb 02, 2015 10:24 am

If you save the DSN as a File DSN, you can edit the DSN file (just a simple text file) to store the username and password. This way it's not so easily visible in any command you publish. Here's how to do that:
http://forums.eviews.com/viewtopic.php? ... 300&p=7745

You could also put it into the wfopen command link this:

Code: Select all

wfopen(type=odbc) dsn=MYDSN;uid=USERNAME;pwd=PASSWORD;database=MYDATABASE "select * from tablename" @freq a @id @date(datecol) @smpl @all
The actual labels here (uid, pwd, database, etc.) may be different with different odbc drivers. You'll have to experiment with your ODBC driver to see what works for MySQL.

Steve

elias41
Posts: 25
Joined: Mon Jun 10, 2013 1:20 am

Re: Fetch (write) data from (to) MySql workbench

Postby elias41 » Tue Feb 03, 2015 4:21 am

Many thanks Steve!
Inittially it didn't work cause I used a 32-Bit connection config, after I reinstalled the necessary 64-Bit driver it worked perfectly!

EViews Steve
EViews Developer
Posts: 844
Joined: Tue Sep 16, 2008 3:00 pm
Location: Irvine, CA

Re: Fetch (write) data from (to) MySql workbench

Postby EViews Steve » Tue Feb 03, 2015 8:37 am

No problem.

Yeah I should've mentioned that. 64-bit EViews will require 64-bit ODBC, while 32-bit EViews will require 32-bit ODBC. For some reason, even though the ODBC drivers are technically COM objects, you can't use them cross-bit.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests