In this tutorial we will be walking you through how you can connect to your databases whether it might be Relational – SQL Server, Oracle, DB2, MySQL, PostgreSQL or Big Data – Hive, Apache Spark, or SaaS – Salesforce, Eloqua etc., using an ODBC driver. As an example, we will show you how you can connect to SQL Server using DataDirect ODBC driver.
Have Julia installed on your machine


julia> Pkg.add("ODBC")
julia> ODBC.drivers()
julia> ODBC.dsns()
db = ODBC.DSN("SQLServer", "username", "password")
df = ODBC.query(db, "SELECT * FROM Chinook.dbo.Artist")println(df)
csv = ODBC.query(db, "select * from Chinook.dbo.Artist", CSV.Sink, "Artists.csv")
ODBC.execute!(db, "CREATE TABLE [Chinook].[dbo].[Artist2]([ID] [INT] NOT NULL,[Name] [nvarchar](120) NULL)")
ODBC.execute!(db, "INSERT INTO Artist2 VALUES (472, 'Saikrishna Bobba')");
ODBC.disconnect!(db)
using ODBCusing CSV#list all driversprintln(ODBC.drivers())#list all ODBC DSNSprintln(ODBC.dsns())#Connect to ODBC DSNdb = ODBC.DSN("SQLServer", "username", "password")#Query your Database, return result as dataframedf = ODBC.query(db, "SELECT * FROM Chinook.dbo.Artist")println(df)# Query your database, return result as CSV filecsv = ODBC.query(db, "select * from Chinook.dbo.Artist", CSV.Sink, "Artists.csv")#Create TableODBC.execute!(db, "CREATE TABLE [Chinook].[dbo].[Artist2]([ID] [INT] NOT NULL,[Name] [nvarchar](120) NULL)")#Load data ODBC.execute!(db, "INSERT INTO Artist2 VALUES (472, 'Saikrishna Bobba')");#disconnectODBC.disconnect!(db)
Feel free to try any of our ODBC drivers to connect to your databases from Julia. If you have any questions or issues, please contact us.