diff -r 54d7f1486ac4 -r 4daf47fcf792 script/iri_tweet/export_tweet_db.py --- a/script/iri_tweet/export_tweet_db.py Tue Jan 18 10:08:03 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -from models import * -from utils import * -from optparse import OptionParser -from sqlalchemy.orm import sessionmaker -import logging -import sqlite3 -import sys - - -# 'entities': "tweet_entity", -# 'user': "tweet_user" - -def get_option(): - - parser = OptionParser() - - set_logging_options(parser) - - return parser.parse_args() - -if __name__ == "__main__": - - (options, args) = get_option() - - set_logging(options) - - with sqlite3.connect(args[0]) as conn_in: - engine, metadata = setup_database('sqlite:///'+args[1], echo=((options.verbose-options.quiet)>0)) - Session = sessionmaker(bind=engine) - session = Session() - try: - curs_in = conn_in.cursor() - fields_mapping = {} - for i,res in enumerate(curs_in.execute("select json from tweet_tweet;")): - logging.debug("main loop %d : %s" % (i, res[0])) - processor = TwitterProcessor(eval(res[0]), res[0], session) - processor.process() - session.commit() - logging.debug("main : %d tweet processed" % (i+1)) - except Exception, e: - session.rollback() - raise e - finally: - session.close() - - - \ No newline at end of file