Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

repairs script to handle case (apparently sqlite LIKE is not very goo…

…d), force upper() instead
  • Loading branch information...
commit 298bd647d107c4a479d274be61583c6426ad7029 1 parent 3375339
@msenateatplos msenateatplos authored
Showing with 15 additions and 8 deletions.
  1. +15 −8 update_locations.py
View
23 update_locations.py 100644 → 100755
@@ -6,23 +6,27 @@
import sqlite3
import time
+# Connect to db
conn = sqlite3.connect(database)
c = conn.cursor()
+# start logging
+logger = logging.getLogger('main.update_locations')
+
+# Store response of query
res = c.execute('''
SELECT
- s.location_city,
- s.location_state
+ upper(s.location_city),
+ upper(s.location_state)
FROM signatures as s
LEFT OUTER JOIN locations as l
- ON l.location_city = s.location_city
- AND l.location_state = s.location_state
+ ON l.location_city LIKE s.location_city
+ AND l.location_state LIKE s.location_state
WHERE l.loc_id IS NULL
-GROUP BY s.location_city, s.location_state
-limit 5
+GROUP BY upper(s.location_city), upper(s.location_state)
''')
# @TODO
@@ -31,12 +35,15 @@
# locations.append(row)
locations = []
-for row in col:
+for row in c:
+ locations.append(row)
+
+for loc in locations:
insert_values = "(null, :city, :state)"
loc_dict = {"city": loc[0],
"state": loc[1]}
c.execute("INSERT INTO locations VALUES " + insert_values, loc_dict)
- logger.info("Inserting... city: " + loc_dict[0] + " state: " + loc_dict[1])
+ logger.info("Inserting... city: " + unicode(loc_dict["city"]) + " state: " + unicode(loc_dict["state"]))
conn.commit()
c.close()
Please sign in to comment.
Something went wrong with that request. Please try again.