Skip to content

Commit 48289c3

Browse files
committed
0.2.3
use /tmp folder
1 parent 697c72f commit 48289c3

3 files changed

Lines changed: 14 additions & 5 deletions

File tree

uszipcode/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.2.2"
1+
__version__ = "0.2.3"
22

33
if __name__ == "__main__": # pragma: no cover
44
print(__version__)

uszipcode/db.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
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")
2727
db_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

3333
def is_simple_db_file_exists():

uszipcode/search.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import math
99
import heapq
1010

11+
import sqlalchemy as sa
1112
from collections import OrderedDict
1213
from sqlalchemy.orm import sessionmaker
1314
from 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())

0 commit comments

Comments
 (0)