Ramblings

March 10, 2008

Elixir: Simple sweet access with SQLAlchemy behind the scenes

Filed under: dev, python, web2py — michaelangela @ 9:21 am

I really like using web2py. I only have one major problem with developing with it. I like code completion and other good things that come with developing in an IDE.

First off, SqlSoup for SQLAlchemy. Very cool. It’s got runtime introspection which, in plain English, means that you can experiment with the database, seeing what is available, etc., without always having to keep the whole thing in your head. The only thing I don’t see it doing, so far, is being able to tell you which tables are available at runtime. Somebody tell me if I am wrong! But I digress.

With web2py’s orm, there are a lot of neat functions. It’s cool. I have used it a bit differently though. That’s for another post. I wrap specific calls as methods in the model so that I can always update things in one place. I am trying to keep it DRY. I need to change how I get whatever specific value? I change the method at the model level. That’s something I got used to with Django. I like it, it works for me, and it’s helpful.

The side effect of doing that, especially since I use classes in my models for web2py, is that I get code completion for that in my IDE. I use PyDev in Eclipse. I think I really started to like that. So I thought, “It would be neat to get to the fields of my database objects while in the IDE.”

The first step was SqlSoup with it’s runtime introspection. The next step is Elixir with it’s simple (drop dead simple) database class setup.

Elixir – Trac

How would I use it with web2py? Keep the standard web2py define_table calls. This allows me to keep the use of the admin and other functions that run off of web2py’s orm, like SQLFORM, SQLTABLE, and other things. Then, in an ideal world, I could setup models with Elixir and be able to use SQLAlchemy with web2py. I just have to remember to not use the autoload or autosetup options, and to use “setup_all(create_tables=False)” so that it doesn’t try to re-build the tables.

I like web2py’s orm but I am still debating some things about it. It’s not that it is bad or anything, just balancing things as I learn and develop.

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: