Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use match when doing copies to db #8151

Open
GeoWill opened this issue Nov 11, 2024 · 0 comments
Open

Use match when doing copies to db #8151

GeoWill opened this issue Nov 11, 2024 · 0 comments

Comments

@GeoWill
Copy link
Collaborator

GeoWill commented Nov 11, 2024

specifically here:

class AddressbaseUpdater(BaseImporter):
def get_table_name(self):
return "addressbase_address"
def import_data_to_temp_table(self):
copy_string = f"""
COPY {self.temp_table_name} (UPRN, address, postcode, location, addressbase_postal)
FROM STDIN
WITH (FORMAT CSV, DELIMITER ',', QUOTE '"');
"""
self.stdout.write(f"Executing: {copy_string}")
with open(self.data_path) as f:
self.cursor.copy_expert(copy_string, f)
class UprnToCouncilUpdater(BaseImporter):
def get_table_name(self):
return "addressbase_uprntocouncil"
def import_data_to_temp_table(self):
copy_string = f"""
COPY {self.temp_table_name} (uprn, lad, polling_station_id, advance_voting_station_id)
FROM STDIN
WITH (FORMAT CSV, DELIMITER ',', null '\\N');
"""
self.stdout.write(f"Executing: {copy_string}")
with open(self.data_path) as f:
self.cursor.copy_expert(copy_string, f)

Ref https://github.com/DemocracyClub/uk-geo-utils/pull/33/files#r1836749158

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant