def save_to_postgres(self, tweet):
     insert_str = utils.tweet_to_insert_string(tweet, self.psql_table, self.psql_cursor)
     try:
         self.psql_cursor.execute(insert_str)
         self.psql_connection.commit()
    
     except Exception as e:
         print "Error running this command: %s" % insert_str
         traceback.print_exc()
         traceback.print_stack()
         self.psql_connection.rollback() # just ignore the error
def save_to_postgres(tweet, table, connection, cursor):
    if 'coordinates' not in tweet or tweet['coordinates'] == None or 'coordinates' not in tweet['coordinates']:
        tweet['coordinates'] = {'coordinates': [-999, -999]}
    insert_str = utils.tweet_to_insert_string(tweet, table, cursor)
    try:
        cursor.execute(insert_str)
        connection.commit()
   
    except Exception as e:
        print "Error running this command: %s" % insert_str
        traceback.print_exc()
        traceback.print_stack()
        connection.rollback() # just ignore the error
def save_to_postgres(tweet, table, connection, cursor):
    if 'coordinates' not in tweet or tweet[
            'coordinates'] == None or 'coordinates' not in tweet['coordinates']:
        tweet['coordinates'] = {'coordinates': [-999, -999]}
    insert_str = utils.tweet_to_insert_string(tweet, table, cursor)
    try:
        cursor.execute(insert_str)
        connection.commit()

    except Exception as e:
        print "Error running this command: %s" % insert_str
        traceback.print_exc()
        traceback.print_stack()
        connection.rollback()  # just ignore the error