27/03/2008

Graphing SQLAlchemy Models

Here is a little function to draw a nice graph of your SQLAlchemy tables and foreign keys. Just pass it a MetaInfo instance.

import pydot

def graph_meta(meta, filename="dbgraph.jpeg"):
    d = pydot.Dot()
    nodes = {}

    for table in meta.tables.itervalues():
        n = nodes[table.name] = pydot.Node(table.name)
        d.add_node(n)

    for table in meta.tables.itervalues():
        for c in table.c:
            for fk in c.foreign_keys:
                e = pydot.Edge(nodes[table.name], nodes[fk.column.table.name])
                d.add_edge(e)

    d.write_jpeg(filename)

25/03/2008

Python vs The World

Bleh I really should post more often but Im just not "blog-minded". Ive got a new job since last time, back to php - oh no! ehehe. I even promised I wouldnt try and convert them to Python... guess what?! One and half days later theyre considering switching to Python :) Find out tomorrow morning, wish me luck ;)

What have I learnt from 2 days of php developing again? Its still just as rubbish, the language is horrible and whatever the framework page may say, its not quick, its not good, and its certainly not clever. If your still in php land get off your arse and learn something new! If you discovered php and thought, "hey this is so much easier that XXXX!", maybe you can experience that feeling again.

Anyway, enough of that.. you can find plenty of php bashing ( and if you look hard enough some python devs saying the good points about php ) on the internet.

Something about python... Its pyweek in 5 days! #python3d is going to enter its own group. http://groups.google.com/group/python3d/browse_thread/thread/9827b6b1ac2e7beb for more.

Id like to write some interesting python tidbit now but I cant think of the last interesting thing I found ...