File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- __version__ = "0.2.2 "
1+ __version__ = "0.2.3 "
22
33if __name__ == "__main__" : # pragma: no cover
44 print (__version__ )
Original file line number Diff line number Diff line change 2323 from uszipcode .pkg .atomicwrites import atomic_write
2424 from uszipcode .pkg .sqlalchemy_mate import engine_creator
2525
26- db_file_dir = Path . home (). append_parts ( ".uszipcode " )
26+ db_file_dir = Path ( "/tmp " )
2727db_file_dir .mkdir (exist_ok = True )
2828
29- simple_db_file_path = db_file_dir .append_parts ("simple_db .sqlite" )
30- db_file_path = db_file_dir .append_parts ("db .sqlite" )
29+ simple_db_file_path = db_file_dir .append_parts ("uszipcode_simple_db .sqlite" )
30+ db_file_path = db_file_dir .append_parts ("uszipcode_db .sqlite" )
3131
3232
3333def is_simple_db_file_exists ():
Original file line number Diff line number Diff line change 88import math
99import heapq
1010
11+ import sqlalchemy as sa
1112from collections import OrderedDict
1213from sqlalchemy .orm import sessionmaker
1314from six import integer_types , string_types
@@ -85,6 +86,7 @@ def __init__(self, simple_zipcode=True):
8586 download_db_file ()
8687 engine = connect_to_zipcode_db ()
8788 self .zip_klass = Zipcode
89+ self .engine = engine
8890 self .ses = sessionmaker (bind = engine )()
8991
9092 def __enter__ (self ): # pragma: no cover
@@ -427,7 +429,6 @@ def query(self,
427429
428430 if zipcode_type is not None :
429431 filters .append (self .zip_klass .zipcode_type == zipcode_type )
430-
431432 if zipcode is not None :
432433 filters .append (self .zip_klass .zipcode == str (zipcode ))
433434 if prefix is not None :
@@ -821,3 +822,11 @@ def by_median_household_income(self,
821822 sort_by = sort_by , zipcode_type = zipcode_type ,
822823 ascending = ascending , returns = returns ,
823824 )
825+
826+ def inspect_raw_data (self , zipcode ):
827+ sql = "SELECT * FROM {} WHERE zipcode = '{}'" .format (
828+ self .zip_klass .__tablename__ ,
829+ zipcode ,
830+ )
831+ stmt = sa .text (sql )
832+ return dict (self .engine .execute (stmt ).fetchone ())
You can’t perform that action at this time.
0 commit comments