-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathcodeit.py
More file actions
executable file
·33 lines (28 loc) · 1.11 KB
/
codeit.py
File metadata and controls
executable file
·33 lines (28 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env python3
""" Brute Force program to geocode all clubs into the GEO table """
import googlemaps
import urllib3
import logging
import dbconn, tmparms
import pprint
import os, sys
from uncodeit import myclub
import tmglobals
myglobals = tmglobals.tmglobals()
# Set up global environment
parms = tmparms.tmparms()
myglobals.setup(parms)
conn = myglobals.conn
curs = myglobals.curs
#urllib3.disable_warnings()
#logging.captureWarnings(True)
gmaps = googlemaps.Client(key=parms.googlemapsapikey)
curs.execute("SELECT clubnumber, clubname, place, address, city, state, zip, latitude, longitude FROM clubs WHERE lastdate IN (SELECT MAX(lastdate) FROM clubs) ORDER BY CLUBNUMBER;")
for (clubnumber, clubname, place, address, city, state, zip, whqlatitude, whqlongitude) in curs.fetchall()[0:1]:
print(clubnumber, clubname)
print(address, city, state, zip)
gres = gmaps.geocode("%s, %s, %s %s" % (address, city, state, zip))
pprint.pprint(gres)
print("=================")
club = myclub(clubnumber, clubname, place, address, city, state, zip, whqlatitude, whqlongitude).update(gres, c)
conn.commit()