September 8, 2010

SQLAlchemy = Another great SQL Frameword

Surgical ToolsJust a few days ago, I was talking about how much I enjoy PySqlite, and now I’ve found another great tool for my SQL war chest. SQLAlchemy

I am already using it for another part of a big multi-database reporting project. The fun part for me is that it is more modular and less demanding of structure than SQLObject, so I can actually use its superior raw SQL connection and marshalling capabilities for manual report queries, while continuing to utilize my SQLObject enabled object model.

Very sweet, and very quick to get going on my Mac development and Linux deployment environments. I’m currently collecting data from three different databases (SQLite, PostgreSQL, and MySql) on five different servers. This is a killer app for me.

I’ll be exploring its object-relational capabilities soon, but I am already very fond of the framework, and how lightweight it feels.
[tags]python,sql,sqlobject,sqlalchemy[/tags]

Fixed a WordPress Feedburner Replacement Bug

BugThis morning I logged into Feedburner to check my stats. AAAARGH! 0 subscribers on all my blogs. Seems my upgrade to WordPress 2.0.3 broke the feedburner redirect plugin.

How to fix it

I experimented for a while, and came up with this surefire fix:

  • Login as admin, go to plugins

  • Disable the Feedburner replacement, then re-enable
  • Go to options, then Feedburner.
  • Disable the redirection
  • Click the Feedburner tab again, and re-enable
  • Click "activate"
  • Now edit your .htaccess file on the server.
  • Change this line:
    RewriteCond %{HTTP_USER_AGENT} ^FeedBurner.*$

    to this:
    RewriteCond %{HTTP_USER_AGENT} ^Feed.*$

[tags]wordpress, wordpress2.0.4, feedburner, bugs[/tags]

Discovered the killer combo of Pysqlite and SQLObject

Light BulbAt work, I’m doing a bunch of data acquisition on various machines outside the firewall. I think I’ve hit on an absolutely great combination of Python technologies to do this in a really manageable and scalable manner.

The design constraints:

  • No long-running processes. These are heavily loaded boxes. The data acquisition will run via scheduled cron jobs.
  • No new ports open. I can’t run Mysql on these boxes.
  • No drilling back from these servers into the corporate network. So I can’t run mysql inside and connect from the outside.

The plan

  • Each remote box will run a small python app on a scheduled basis, writing its data to a single file.
  • A "gatherer" system inside the firewall will retrieve the files from all remote machines on an hourly basis.
  • On acquisition, the remote files will be removed.
  • The gatherer process will then merge the remote data into a master Mysql database for reporting.

The technologies

  • PySqlite: will provide access to an on-the-fly generated database file on remote machines.
  • SQLObject: can talk to both PySqlite and Mysql. I simply define the object model using its scheme, and it will happily generate the tables for me in both Sqlite and Mysql. Writing the merge process was the trickiest bit, but it only took a few hours to write and test.

Conclusion

This was an extremely fast development path. I was all the way from concept to deployment in just three days, and I didn’t even know anything about SQLObject or Sqlite at the start.

Contrast that productivity to Java, where a similar project would take at the minimum a couple weeks, and you start to see why I think that Python has become the secret weapon in my developer toolbox.

[tags]python,sqlite,pysqlite,sqlobject[/tags]

iSale Review

iSale ScreenshotLately, I’ve been using iSale to help me list items on eBay using my Mac. I’ve used it enough now that I can give a reasonable review of its functionality.

So far, I’ve listed 10 items using the software. Listing is very straightforward, you simply click on the plus-sign to add a listing, which brings up a blank template. One nice feature is that it automatically brings up the last-used template. After all, once you settle on a template, you are unlikely to want to change very often.

Filling in the template

I simply drag-n-drop pictures from iPhoto to my template. The images are automatically uploaded to your choice of eBay, .mac, or an ftp site when you submit the listing. The program optionally creates a typical eBay "click the thumbnail to enlarge" gallery.

After my images are uploaded, I fill in the title and then click in the various template areas to fill out the template with the "meat" of the listing. This is usually pretty fast, and made even more simple by iSale’s capability to seek out previously used descriptions from eBay and Amazon. Some might find that unethical, luckily I don’t.

I’ve manually edited my favorite template to include my standard terms and conditions. That makes it somewhat faster for me to fill out the template, since it is basically just pictures and a short description at that point.

Filling in the sale data

iSale tries very hard to make the sale data entry process very simple. It preloads all the categories from eBay, so you can narrow into your item’s proper category quickly. It allows you to set all the standard eBay options such as shipment types, gallery, bolding, buy-it-now, reserve price, etc, all from one handy screen. I am constantly using the "scheduled auction" feature, which is simple and accurate. I’ve yet to find anything fail to work properly in this section, which is fairly amazing, if you think about it.

Sale Tracking

While the auction is running, it appears on a dashboard widget with its current bidded price. I thought this was sort of a gimmick at first, but I’m really finding this useful, and much speedier than logging into eBay and looking on my "selling" page.

I haven’t used the shipment helper parts of the program. Honestly, I just noticed them today. I think I’ll try them with the next sale, they might make things a bit more straightforward, automating the shipping receipt for me.

Conclusions

Pros:

  • The program is strong and mature.
  • It always seems to work properly, and just as expected.
  • It certainly is much faster than manually listing with hand-coded HTML. Why bother hand-coding for a throwaway thing like an auction?
  • The templating system works well
  • The iPhoto integration is a killer feature.
  • The dashboard widget is very useful for tracking auctions.

Cons

  • The templates are difficult to edit. I had to guess and experiment to hack in a custom template which was just the way I wanted it, while keeping the iPhoto and text-template-block stuff intact. I acknowledge that this might be described in a document somewhere, but I certainly couldn’t find it.
  • I think the "corkboard" for auctions looks cheesy, and I wish I could turn it off.
  • Summary

    This program is a complete winner for my purposes, I give it an 8 out of 10. If it had an integrated template editor, I’d give it a 10.

[tags]iSale,eBay,reviews,mac[/tags]