def main(): description = """Search geotagget tuits""" parser = argparse.ArgumentParser(description=description,formatter_class=RawTextHelpFormatter) parser.add_argument('-lat', '--latitude', action='store', help='latitude in decimal format', required=True, dest='lat') parser.add_argument('-long', '--longitude', action='store', help='longitude in decimal format', required=True, dest='long') parser.add_argument('-rad', '--radius', action='store', help='radius in km', required=True, dest='radius') parser.add_argument('-c', '--carcel', action='store', help='String used as representadion of carcel:\n\t* diroes', required=True, dest='carcel') args = parser.parse_args() create_database() radius = re.search("([0-9]+)", args.radius.strip()).groups()[0] + "km" latitude = args.lat.strip() longitude = args.long.strip() carcel = args.carcel.strip().lower() geocode = latitude + "," + longitude + "," + radius fetch_tuits(geocode)
def last_date_in_db(): lib.create_database() filename = os.path.join(config.base_folder, "visitas.db") db = dataset.connect("sqlite:///" + filename) res = db.query("select date from visitas") dates = [] for i in res: i = i['date'].split("/") dates.append(date(int(i[2]), int(i[1]), int(i[0]))) dates.sort() return dates[-1]
# -*- coding: utf8 -*- import dataset import codecs import lib import hashlib db = dataset.connect("sqlite:///visitas.db") table = db['visitas'] lib.create_database() items = lib.get_data() table.insert_many(items)