import evertracker import types evertracker.init_database() cur = evertracker.g.con.cursor() cur.execute("SELECT * FROM torrents") if type(cur.fetchone()) == types.NoneType: tor = "gentoo.torrent" evertracker.add_torrent(tor) print "Torrent %s added to database."%tor