Connecting Julia to DB2 LUW database

Fairly new to Julia. I am trying to determine if it is possible to query a DB2 LUW database directly with Julia and I haven’t found any definitive answers so far. Does anyone here happen to know? Is there a package I can load to help with such a connection? If I use ODBC, is there something I need to do outside of Julia to ensure a connection is possible? Thanks!

You should be able to use ODBC (or even JDBC…), wouldn’t it be good enough (its purpose in life is so that not all need their own driver)?

There’s no direct DB2 driver for Julia that I know of, unlike e.g. Oracle.jl, and for all major open source.

I think DB2 (like Informix, that IBM bought) might be too obscure. But if you find a driver in e.g. C, you could call it. You could also call to SQLAlchemy in Python, in case better, and it supports IBM, through PythonCall.jl.

I did google, and found a company that connects most anything e.g. Db2, to most anything, or at least gets the data into, also Julia

In case helpful:

Thanks Palli - I think I understand most of what you were saying but some is over my head. I think the right approach will be to use ODBC. But if I use ODBC, I think I need a specific DB2 driver…and if that is the case, I am unclear on how to identify the specific driver and I might also have a corporate firewall that prevents me from doing that myself. Thanks!!!

You you need a DB2 specific driver. You always need that at some level.

If you use ODBC you have to set it up and that part is neither Julia specific.

It depends on where your software runs (the database can be elsewhere), on what operating system, here infor on e.g. Windows:

The point of ODBC (also of JDBC) is that the driver only needs to support ODBC, and the app has to support ODBC. I.e. you do not have N (number of databases) times M (number of apps or programming languages) combinations, rather N + M solutions, to choose from.

But that means I’m only helping you with half the problem, above, and you should get that to work first. And I don’t known what operating system you are using, why I wasn’t more specific at first. For the other half you use ODBC.jl. If not good enough, or you wanted some kind of direct connection, that doesn’t seem available with Julia one, then I suggested SQLAlchemy, and only then do you need to know about PythonCall.jl.

If Db2 had a Julia specific driver package available it might actually be installable, and would set everything up for you. But the Julia Pkg manager can’t do it, since there’s no specific package for Db2, then you need to to it this indirect way, and that’s also ok.

ODBC isn’t some kind of limitation, it’s the solution (one of JDBC if you use Java). Supporting databases was a different story before it came along. And I checked if some languages have some direct access, e.g. Java and the hugely popular PHP, and I only found ODBC used with PHP, and what you learn there or from other languages supporting ODBC will translate, while not identical:

Hope this helps.

Super helpful!!! Thank you! I am going to download the driver for IBM DB2 LUW and once that is installed, I think I should be able to connect. Will let you know.

I have SQLAlchemy installed but I’ve never used PythonCall.jl, so not sure how to actually do that.

1 Like