How can I fetch data from MySQL database in Julia?
It looks like this package provides tools for connecting to any database, including MySQL. However, it looks like assuming I have to first setup ODBC DSN to connect to it (I don't know what it is in the first place, although I've used MySQL for two years). So I tried to configure it by reading this page at MySQL documentation... but hit the wall immediately.
One, I can't find a command named myodbc-installer in my OS X 10.8.5. Two, there is no such application called ODBC Administrator, and instead there is ODBC manager in my system - So I think that documentation is too outdated... right?
Also, even when I opened ODBC manager and tried to click on Add on User DSN tab, there are no driver detected on the screen. So how can I configure ODBC DSN and make use of MySQL in Julia?
Also, do I have to deal with such a tedious setup process? I'd like to use a package, if any, that is as intuitive and easy to use as RMySQL package in R, which doesn't force me to care about DSN - any such package in Julia?
I'm on 0.2.0-rc in Julia and already installed the package through Pkg.add("ODBC"). MySQL version is 5.3.6 and installed via MAMP.
Thanks.
Jacob Quinn here, package maintainer for the ODBC package for Julia.
A few things to help you understand how the process works:
-ODBC is an API middle layer originally developed by Microsoft to create a common interface between DB systems and applications. This was useful because with the number of different DB systems, it would be hard to have applications that could reliably connect to any DB.
-ODBC has been ported to Linux/Unix/OSX systems through 2 main projects: iodbc (mainly OSX) and unixODBC (Linux)
-The basic components of the API are the ODBC Manager, which is the middle layer, the DB system, the application, and the ODBC driver, which is DB-specific and actually implements the communication between application-ODBC Manager and ODBC Manager-DB system.
-In the case of RMySQL, only the MySQL driver has been implemented with R wrapper functions which allow the connection to MySQL DB systems
-In the case of ODBC.jl (and the corresponding RODBC for R), a more generalized approach is taken where wrapper functions of the ODBC Manager are provided, which allow connection with any DB system, provided the user has the correct DB driver installed and connection string
Hopefully that helps understand the ODBC process a little better.
So for your case, it looks like you don't have the MySQL driver installed since it didn't show up in your ODBC Manager. You can find the driver here.
Once you have the driver installed, it should be pretty simple to set up a DSN (following either MySQL documentation or the excellent connectionstrings.com, MySQL Section).
You should then be able to start using ODBC in julia:
Pkg.add("ODBC")
using ODBC
ODBC.connect(dsn)
query("select * from customers")
If you run into any other issues or troubles getting things setup or installed, feel free to open an issue here and I'm more than willing to help troubleshoot the setup to get you going.
Related
I was wondering if it is possible to create custom MySQL servers in VB.NET while working in visual studio at runtime so that if the server already exists it connects and if it isn't there, the code creates the server. I have searched for this everywhere but couldn't find anything. I would appreciate it a lot if someone guides me to the right path.
You could certainly write some .net code to start a MySQL server on your Windows box when an attempt to connect fails. You simply get a cmd.exe console with administrator privileges and give the command net start mysql.
But MySQL must already be installed on the box for that to work.
You might investigate Sqlite. It provides SQL locally to a .net program, storing your tables in a file called whatever.db. It has very similar .net API access to MySQL's Connector/Net and SQL Server's connector. It's in a NuGet package.
I don't completely understand your "custom MySQL servers" requirement. Sqlite gives you a way to use SQL in your application without connecting to a shared server. That may do what you need.
MySQL does have a CREATE SERVER statement in its SQL dialect. The purpose of this statement is to create a connection to another, remote, MySQL server. With that connection you can use the FEDERATED storage engine to access tables in the remote server. Of course, there is no way to run this CREATE SERVER statement unless your program is already connected to a MySQL server.
With respect, your "task which states to create a server at runtime" doesn't make much sense. Is there more to this requirement? What workflow needs this step? Is it part of the installation of some application software on a new box?
I'm working with a remote Oracle database and would like to create a link to a local MySQL database on my Macbook Pro. From what I've read it sounds possible, but I'm not sure how to get things setup.
I believe I need ODBC connection info setup on my Mac in the odbc.ini file. I can't find where that file should be, or what info to enter into it. I've come across Mac app "ODBC Manager" which looks like it should help with setup, but I see no instructions on how to use it. Can ODBC connection info be setup through other clients like Sequel Pro or SQL Developer?
I'm currently running Mac OS X 10.10.5 (Yosemite). I could update to Sierra if that would make the odbc setup/linking easier.
Thanks,
Steve
You don't need to upgrade OS X, in any case.
Are you trying to make MySQL consume data from Oracle? I do not believe this is possible.
Or make Oracle consume data from MySQL? This is done with DG4ODBC, an Oracle helper application, as Oracle -> DG4ODBC -> ODBC driver for MySQL -> MySQL.
DG4ODBC is available for various platforms (which do not include OS X). You'll need an ODBC driver for MySQL (such as those from my employer) installed on the same platform; DG4ODBC will need to be TCP/IP accessible by Oracle from its host; and MySQL on your Mac will need to be TCP/IP accessible by DG4ODBC from its host.
I have a task to Migrate MySQL DB to Oracle (its my requirement) i tried to Migrate using SQL developer as defined in below link.
https://www.packtpub.com/books/content/migrating-mysql-table-using-oracle-sql-developer-15
As the DB is huge, the constraints are not copied properly from MySQL to Oracle, i need to define/alter/add constraints explicitly, which is time consuming (SQL developer migrates data 300rec/min from mysql to Oracle) & the entire procedure, views, functions is need to re write.
How can i ensure that data has migrated properly or not.?
Is this is a right approach to migrate?
Should i move to any tool which helps to Migrate? If yes please suggest the tool..!!
Or it is the right thing to Move from MySQL to Oracle.
Thanks in Advance.
No specific answer, but some genaral thoughts based on my experiences with migration.
I've found that there normally isn't one tool that does the whole migration job well, and by whole job I mean:
Fast
Handles all data types, scenarios
And that is from Oracle to Oracle!!
Last project we tried Oracle Golden Gate, and found there were issues with that.
We always end up with a hybrid approach, somethings like:
Extract all DDL manually and pre-create objects - there are weaknesses in the stagndard tools that confound them when extracting DDL, e.g. we found 10g expdp did not handle some quirky PLSQL well, so we resorted to extracting this ourselves.
Some tables work well with SQL Loader, others with GG, others (rare) with a custom extract and load process. We had over 3,500 tables and identified about 100 that worked better done as SQLLoader rather than GG. When I say better I mean with data handling and speed of migration. We created different groups of processing each group having a different method.
Once we have an overall hybrid scheme that works, we tune, mainly by splitting that task into parallel processes, both the export and import side.
All my migrations have been big projects where we have shifted from one Oracle system/server to another, always with the target being a newer version of OS and Oracle.
So, I would imagine that migration between non-Oracle and Oracle will through up even more challenges, and probably not as trivial as imply clicking a few buttons in SQL*Developer.
You may find the expected content from the SQL developer documentation at the Oracle website.
There are migration information available for all Microsoft Access users, MySQL users, Microsoft SQL Server and Sybase Adaptive Server users.
You can also download the tutorial in forms of PDF (best for offline viewing and printing), ePub (best for most mobile devices) and Mobi (best for Amazon Kindle devices).
Recently, I have successfully migrated the MySQL database to Oracle database. Below are detail steps:
Operating System: Desktop Ubuntu local and Desktop Ubuntu on amazon aws
Please Note: Here I am using aws desktop ubuntu server because my mysql
database was pretty big. In my case there were 800 tables, 200 views,
procedures, triggers, and functions. The total size of the database was almost
20GB. In case of small database I would recommend to use local ubuntu server.
Tools Used: SQL Developer, VNCServer, Remote Desktop Client, JAVA 8, Third Party MySql JDBC Driver
1. Setup ec2 ubuntu desktop server : https://www.youtube.com/watch?v=ljvgwmJCUjw
2. Install SQL Developer on #1
Download the SQL Developer package from this link :
http://www.oracle.com/technetwork/developer-tools/sql-developer/downloads/index.html
Accept the license agreement and download "Other Platforms" for ubuntu.
Install the SQL developer package as the following.
sudo apt-get install sqldeveloper-package debhelper openjdk-7-jdk
openjdk-7-jre icedtea-7-plugin
Now all that you need to do is to run the command (you might have a
different version)
make-sqldeveloper-package sqldeveloper-4.1.3.20.78-no-jre.zip
This will generate a debian package that you can use to install SQL developer.
Now install the resulting .deb package using the command (Your deb
might have a different version too)
sudo dpkg -i sqldeveloper_4.1.3.20.78+0.2.4-1_all.deb
In my case, I have used java 8.
3. Once you have done with your SQL developer installation on your newly created ec2 instance with VNCServer then all you need to do is to connect to that ec2 instance with the Remote Desktop Client by default available in your ubuntu local machine.
Use IP:1 with user/pass setup for VNCServer in #1
You can see the remote ec2 ubuntu desktop server. You have to grab the keyboard inputs from the Remote Desktop tool if you want to tab inside the remote server.
Once you get connected with the remote client, open SQL Developer from the terminal or from the explorer.
sqldeveloper
Follow the migration steps provided by Oracle corporation:
http://www.oracle.com/technetwork/database/migration/mysql-093223.html
Please Note: While following the migration steps provided by the
oracle they will ask for the destination database connection i.e. oracle
database connection. This is not the database where your MySQL
database will be migrated. Instead, this database connection will
be used for the migration process. Your database connection user
must have user and database create privileges. Once your connection
have user create privilege, then migration process automatically create
the corresponding database user in Oracle database[if you have mysql_test_db in MySQL
database, same mysql_test_db will be created in Oracle db too].
I recently used sqline's tool http://www.sqlines.com/cmd to convert a dump from mysql in the form of an .sql script to an (almost) Oracle-compatible sql script.
sqlines31113\sqlines.exe -s=mysql -t=oracle "-in=$infile"
I just had to (semi-manually) fix some things in the output and then I could run it on my oracle database.
I'm using Sparx Enterprise Architect version 9.2 to import a database schema from a MySQL database using the ODBC connection. When I test the ODBC connection using the ODBC Data Source Administrator (Windows 7), the connection tests successfully. I'm using the MySQL ODBC 5.1 driver.
In Enterprise Architect when I try to use this ODBC connection to import the schema I get a message saying, "Unable to obtain table information".
Am I missing something? Any ideas?
The information provided by PsiX is helpful and relevant, but not the piece I was missing. The missing info can be found here, which applies even though it's talking about PostgreSQL (because it's being accessed through ODBC either way). Here is the pertinent information from the link above:
If you are using a 64-bit operating system:
• Enterprise Architect
requires 32-bit ODBC drivers to connect to a repository through ODBC;
to set up the ODBC configuration on 64-bit clients, run the 32-bit
ODBC Data Source Administrator from C:\Windows\SysWOW64\odbcad32.exe
• You can quickly load the correct 32-bit ODBC Data Source
Administrator by selecting Tools | ODBC Data Sources in the
Enterprise Architect menu bar
This piece of information was, unfortunately, omitted in the instructions for setting up Enterprise Architect for MySQL. (Too bad I hadn't noticed the option under Tools previously. Some of us have to do things the hard way!) Thanks again for the info provided by PsiX. It may be just what the next person needs so I'll give it an up-vote. :-)
Did you use the correct ODBC driver?
32 vs 64 bit is relevant here.
Did you check the two checkboxes as described in the installation of the driver?
(Select the Return matched rows instead of affected rows and Allow big result sets checkboxes.)
See here for a detailed description
I've been wondering what are the benefits of using an ODBC driver to interface with a MySQL server? What advantage does that have over directly connecting to the server via TCP and firing off your SQL commands directly?
I'm working with a code base written in labVIEW that references a UDL file which references a data source and its associated ODBC driver to handle the connection to the server. I'm not yet convinced its necessary. I can see the benefit of using a driver if you are connecting to Microsoft Access or excel but if your recipient is an SQL server of some type why would you need a middle man to handle your SQL commands?
I have used the ODBC driver 3.51 for connecting to MySQL Community Server 5.1 for some time now. The ODBC driver allows you (on a Windows computer) to add your MySQL connection to the ODBC data sources list. Now you can reference this data source in many compatible applications. I have been able to use this ODBC connection in VB.Net applications as well as proprietary applications for printing and other functions with ODBC functionality.
I would say that when coding web or python applications i always use the built in MySQL packages, but if you need to access your data through VB.Net or another proprietary application (like a stand-alone windows app) you probably need to set up a system ODBC data source to access your database. To me the ODBC lets Windows access MySQL easily. Without Windows i don't think you need it.
Why ODBC and not JDBC? Some reasons come to mind in order of helpfulness when using JDBC:
Standard api to access the results from a query. To iterate over the results and to get the actual values with the appropriate type.
No need to know how the protocol works to connect to the server. Just use the host, user, password, send the SQL and iterate over the result.
Abstract out the connection to the database. Changing the database should be simpler.
Standard way to commit and rollback for transaction based changes.
In my experience, JDBC is very verbose. You need to write many lines to accomplish simple things. I've found the Spring JDBCTemplate wrapper to be an extremely easy to use alternative for simple stuff.