By Antonio Cangiano, Software Engineer & Technical Evangelist at IBM
Currently Browsing: Django

DB2 on Mac

Python and DB2

We now have a working Python driver for DB2 which is currently undergoing internal testing. The driver is similar to the Ruby and PHP ones, which means that you get an advanced and very easy to use API. It also means that if you are confident with the Ruby driver, you will be able to use the Python one in no time.

Ruby:

require 'ibm_db'

conn = IBM_DB::connect(database, user, password)

if conn
  puts "Connection succeded."
  IBM_DB::close(conn)
else
  puts "Connection failed."
  puts IBM_DB::conn_errormsg
end



Python:

import ibm_db

conn = ibm_db.connect(database, user, password)

if conn:
    print "Connection succeeded."
    ibm_db.close(conn)
else:
    print "Connection failed."
    print ibm_db.conn_errormsg


We made it so that if you know one, you already know the other. These drivers are CLI wrappers that provide you with performance and stability. Also they don’t limit you to user data and are able to retrieve a good deal of metadata about your database. We’ll also provide a thin wrapper for those of you who intend to use a PEP 249 API. The next step, working on SQLAlchemy, has already started.

DB2 on Mac (no, really!)

macpro.pngWhen I first posted about our interest in Python/Django and DB2, the comment thread got hijacked by many people who asked for a Mac client in order to develop on Mac and deploy on Linux. Ask and you shall receive. I’ve promoted the idea of Django/SQLAlchemy/Python in IBM for a while now, and we are finally close to delivering the driver (with the adapter progressing at the same time too). Well, don’t take this as an official announcement, but Python wasn’t the only thing that I’ve been promoting for months within IBM. With the ever growing community of Ruby/Python hackers adopting Mac as their development platform of choice, I strongly believe that an investment in porting the great free version of DB2 to Mac is a very valid one.

I couldn’t talk about this for weeks, and it must be viewed as a rumor until IBM makes an official announcement, but we have been working on porting DB2 to Intel Mac. Not just the client, the whole package. This makes me a happy panda, no longer will a virtual machine be required to develop with DB2 on Rails on my Mac Book Pro. It’s a joy to see DB2 Express-C run on a Mac Pro (shown in picture) next to the other black boxes in the lab. Work is still in progress, but we should have a beta out there relatively soon (before winter kicks in). DB2 Express-C on Mac is intended for development purposes rather than production, this means that we expect you to develop on your shiny Mac but deploy on Linux or Windows. DB2 on Mac will be a beta product, but again it won’t just be a client runtime, it will be the full product and there is no reason why it shouldn’t be just as stable and efficient as the Linux and Windows versions.

Time to employee some of the newly acquired Cocoa-fu. I’m starting to feel that I could even learn Wasabi and IBM would still be able to let me use that skill in my day job. Awesome.


Python, Django and DB2 Status Update

python-logo.pngPython 3000′s first alpha release was made available last week, and as to be expected, it gathered a lot of interest from the development community. With Python on everyone’s lips, let’s talk about Python in this post as well.

Python and DB2

Back in March we gathered an overwhelming amount of feedback in regards to IBM’s interest in developing a reliable driver and adapter for Python and Django, just like we did for Ruby and RoR. We considered your feedback and took action. I’m glad to be able to “leak” some news to you: our team in the States has been working hard on an advanced driver whose initial development is about to be completed. A closed beta is expected to take place relatively soon, but not immediately.

The Python DB2 driver will be the stepping stone and we have decided to proceed with the creation of an adapter for SQLAlchemy first, and for the default Django ORM next. Enabling SQLAlchemy and DB2 means going further than just Django. It means automatically providing support for any framework that builds on top of it. The development of these adapters should not require too much time. Building a modern, fast and reliable driver was our number one priority and the most challenging part, but now that that component is almost complete, the rest should be smooth sailing from here on out.

Pythonistas’ reactions

In the last few weeks I’ve received many emails in regards to requests about Python and DB2. I have yet to finish replying to everyone, so I thought I would proceed with a public update. Some of these emails are very interesting because they come from very prepared programmers who are willing to help and have good ideas for creating plugins that exploit the unique features of DB2 like pureXML, DB2 Spatial Extender, and so on. Many people see the big potential of having DB2 working with Python, SQLAlchemy and Django, and are really looking forward to it.

The Rails community seems to be more oriented towards MySQL while the Django/Python one leans towards the historically more feature-rich PostgreSQL. I wonder if this difference explains the wider interest amongst pythonistas in seeing a best-selling, high-quality database like DB2 become available.

DB2 Express-C

As a remainder, for those of you who may not be in the loop, DB2 Express-C is an awesome free version of DB2 that doesn’t pose any limits on your database size, connections or users. You can run it on any server with up to 4GB of RAM and 4 CPU cores (the limit is in the license; the code is essentially the same as that of the more expensive versions). You also get native XML storage and querying, high performances and endless scalability. It won’t cost you a cent, but should you require it, you can optionally purchase one year support and get High Availability Disaster Recovery as well at a very competitive price per server.

There is a bigger surprise in the making, and this should be available in a month or so. However I’m absolutely not able to talk about it for the time being, so I’ll have to leave you hanging. As usual, it will be covered in this blog in due time, and it’s sure to please many people, so please feel free to subscribe to this blog by feed or by email if you haven’t done so already.


PlanetDB2.com and a couple of updates

Planet DB2The website PlanetDB2.com is a DB2 blog aggregator that is about to be launched in a few days. If you work with, or are interested in, DB2, you may want
to take a sneak peek and subscribe to the feed.

Everyone who blogs regularly about DB2 is welcome to add their feed, whether you are an IBMer or not, by just getting in touch with us at join [at] planetdb2.com.

I also have a quick update in regards to Python, Django and DB2. I’d like to thank everyone who took the time to contribute to the discussion. The amount of feedback received was very encouraging and it has been carefully collected and will
be taken into serious consideration. I’ll provide updates within this blog,
as soon as news comes up from the dedicated development team at IBM.

Lastly, since publishing the first Ruby Shootout, I’ve received many inquires in regards to a new test run. Testing is in progress and the results, which will include updated versions and new entries like XRuby, will be published relatively soon.

UPDATE (April 15, 2007): The stable version of Ubuntu 7.04 is about to be released. I think it’s worth waiting for a week in order to run the tests directly on this new version.


Python, Django and DB2: we need your input!

I may be biased by the fact that I’m part of the DB2 team, but I think that DB2 Express – C is a kick ass offering for developers who are interested in using an enterprise level database without spending a cent.

Before joining IBM, I too thought DB2 was mostly something for giant companies like Wal-Mart or for mainframe legacy databases that have held information since the seventies. Well, things change, and they change very fast and many of those assumptions are just plain myths.

DB2 Express – C was born from a few people’s desire to bring the power of one of the most advanced databases in the world to developers for free. We had to give in to some small compromises, because IBM is obviously not a non-profit company but… we actually managed to compromise in a way that won’t negatively effect developers too much (shhh, don’t tell anyone ;-) ).

DB2 Express – C is entirely free and the code base is no different from the commercial version. This is a rather different approach from other vendors, whose “express” versions are often crippled by design. There is no database size limit, no limit on the number of instances or databases and no restrictions on the number of users or connections. DB2 Express – C license requires only that it is used on a Linux or Windows server, with a maximum of 4 cores (32 or 64 bit) and 4 GB of memory. That’s it. This is pretty much a generous license given that most developers, startups and even medium sized businesses won’t need anything more than 4 cores with 4 GB of RAM for their dataservers.

I think it’s a very valid offer and probably one of the best propositions available for developers. DB2 is one of the fastest databases in the world and if you outgrow these server boundaries than you are already probably making some serious money and paying for commercial licenses won’t be an issue. :) There is a wealth of information to get you started and a helpful support forum.

This is all dandy and cool, but developers need good drivers and good APIs to access the database from their favorite programming language or framework. This is why there have been many efforts to support Ruby and Ruby on Rails with a native driver and a vendor supported adapter.

But hey, what about Python many people asked? Well, I was one of the first to ask ‘What about Python and Django?’ myself. My team is striving to innovate and embrace the developers’ community, therefore such ideas are immediately considered no matter what it takes. Just to give you an idea, in my team we have a guy who looks like Jimi Hendrix and happily brings his “17 MacBook Pro to work (I’m so jealous about both his Mac and the fact that he still has all his hair :-P ).

Then there is the guy who’s visited hundreds of universities around the world, and has more miles under his belt than a rock star.
It’s a cool team trust me, so in this environment when we see an opportunity to make a concrete step for the community we dive right in.

For a while I’ve been pushing and promoting the idea (within IBM) of a vendor supported Python driver and Django adapter. It looks like the time has come to start considering this seriously and to allocate appropriate resources for it. And I need your help.

I need your feedback and help to collect good ideas, in order for us to create the best driver API that we can. The Python Database API Specification v2.0 – PEP 249 is our starting point, but if you have specific requirements, thoughts or good ideas, please do not hesitate to contact me at my last name @ca.ibm.com or by commenting on this blog. There are no dates or estimated times as we are just in the brainstorming phase, but now is the time for you to give us your input. Take this as a friendly petition and request for feedback, and feel free to contact me even if you are just interested in seeing IBM’s official driver and adapter for Python, Django and IBM databases (DB2 LUW, IDS, etc…).

I thank you in advance and ask you to get the message out there, in the Python and Django communities.

DISCLAIMER: this post expresses my opinions and does not necessarily represent IBM’s positions, strategies or opinions in particular in regards to my colleague’s hair :) .


Keep an eye on djangobook.com

You may want to keep an eye on Django Book today, trusted sources tell me there may be a surprise for you from Adrian and Jacob.

Psstt… don’t tell anyone.


A step by step guide on how to install Django with PostgreSQL on Windows

This is a step by step tip about how to install Django with PostgreSQL on Windows. The links below point directly to the downloads, so the whole procedure should be extremely fast and easy.

  1. Install Python 2.5
  2. Install PostgreSQL 8.1.4
  3. Install the eGenix MX Base package
  4. Extract win-psycopg25.zip
    and copy libpq.dll and psycopg.pyd to c:\python25\DLLs (assuming c:\python25 is where you installed Python).
    You can test that the installation was successful by firing up python and trying: import psycopg. If you are not prompted with an error message, it simply worked.
  5. Get Django 0.95 and uncompress the tar.gz file. If you have problems with this, please use 7-Zip.
  6. If you don’t have setuptools already installed, the Django installation will download and install it for you.
    However the version that Django will attempt to download doesn’t exist on the server,
    therefore we need to specify a different one (the latest).

    Run:

    python ez_setup.py -U setuptools

    within the Django directory and this will install the latest setuptools for you. You can now go to step 7.

    Alternatively if you wish to install setuptools and Django in one step, open in your favorite editor, ez_setup.py located within the Django folder that you just uncompressed,

    and replace the line:


    DEFAULT_VERSION = “0.6c1”

    with

    DEFAULT_VERSION = “0.6c3”

    Now, if the Windows box you’re using has an Internet connection, you’re settle; otherwise just download this file manually into the Django folder.

  7. At this point, open a command prompt and run:



    python setup.py install

NOTE: While it is not recommended, if you wish to use Psycopg2 for some reason, you can skip steps 3 and 4, and use this installer instead.
Then you will need to specify in settings.py: DATABASE_ENGINE = ‘postgresql_psycopg2’ rather than ’postgresql’.


Django is great

It must have been the influence of a few brilliant pythonist friends (particularly Lawrence and Valentino), but over the last few weeks I’ve been dusting off my Python skills.
Python and Ruby
While in my opinion it’s not as elegant as Ruby in terms of language design, Python has better implementation (it’s faster and its libraries are usually better). After being exposed to the brilliance of Ruby for such a long time, I was expecting a different reaction, but writing Python code again turns out to be a pleasurable experience. If you are shopping for programming languages, I highly suggest learning both Python and Ruby. Python documentation is excellent as well, with the tutorial and Dive into Python being two great starting points.

Python has a few nice web frameworks, but I’ve fallen in love for Django. This is an amazing framework similar to Rails, but with a few different design principles. The differences between the frameworks are mainly due to the fact that they were born in different environments (Django was developed as part of a newspaper online, while Rails grew out of Basecamp). The Web has plenty of comparison between the two, so I won’t debate the usual flames here. I’ll simply state that I like what I’m seeing and that the developers clearly know their stuff very well.

A few things that I particularly like:

  • Applications can be plugged and unplugged in one or more projects in no time;
  • A typical project has a very clean structure with only a few files and folders;
  • The Admin interface that’s provided “for free” is very handy for most web applications;
  • Internationalization support is excellent;
  • Django is relatively fast and well optimized in terms of queries and interaction with the supported databases;
  • The template system allows designers to define the UI without having to know how to program in Python. This is a key point. DHH has the opposite philosophy: “My perspective is that designers won’t be creating templates from scratch anyway. Not unless they more or less become programmers.”. I disagree. I recently worked with a brilliant artist, who is a talented Web designer but did not have any experience with Ruby or Rails, and this affected the “agility” of development because she couldn’t just focus on her job, she had to get a bunch of Ruby/Rails skills through out the process;
  • Django documentation is well written and above all much better organized than that of RoR;

On the other hand, Ruby’s syntax and Rails’ magic make the code more readable, but Django/Python code looks pretty good anyways, so it’s not such a big concern.

Speaking of programming languages, lately I’ve shown quite an interest in Haskell and Erlang. With these we can really speak of paradigm shifts, but time is a constraint therefore I’ve only spent enough time to master the basics of Haskell, and enough to whet my appetite with Erlang. At least for the moment, I doubt I will have a chance to go too in depth. Nevertheless I highly suggest them as well, at least to those who have already programming experience and are not afraid to take on new challenges.

For the moment I’ll focus on Ruby on Rails and Django.
If you haven’t done it yet, give Django a shot, following this nice tutorial.


Next Entries »

Copyright © 2005-2010 Antonio Cangiano. All rights reserved.