Skip to content

Commit a1100e9

Browse files
authored
Allowing default parameter of db_path (#8)
1 parent 395af76 commit a1100e9

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

src/catalyst_ons_geographies/postcodes.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@
44
import duckdb
55

66

7-
def get_ons_from_postcodes(postcodes):
7+
def get_ons_from_postcodes(postcodes, db_path='/data/ons_postcodes.duckdb'):
88
'''Get the ONS Geography data from the postcodes'''
99

1010
# The path is either data/ or /data/ depending on the environment
11-
db = '/data/ons_postcodes.duckdb'
12-
if not os.path.exists(db):
13-
db = 'data/ons_postcodes.duckdb'
11+
if not os.path.exists(db_path):
12+
db_path = 'data/ons_postcodes.duckdb'
1413

15-
conn = duckdb.connect(database=db, read_only=True)
14+
conn = duckdb.connect(database=db_path, read_only=True)
1615

1716
# For all postcodes in the postcode array, remove any whitespace
1817
postcodes = [postcode.replace(' ', '') for postcode in postcodes]

0 commit comments

Comments
 (0)