Skip to content

Load null-geometry rows in bc2pg with COPY - #293

Merged
smnorris merged 1 commit into
mainfrom
fix-bc2pg-null-geom-copy
Nov 26, 2026
Merged

smnorris merged 1 commit into
mainfrom
fix-bc2pg-null-geom-copy

Conversation

@smnorris

Copy link
Copy Markdown
Collaborator

Rows with no geometry were written with a plain DataFrame.to_sql insert. Under psycopg 3, SQLAlchemy casts object columns to VARCHAR in that insert, and postgres rejects VARCHAR values for DATE columns, so tables with null-geometry rows and date columns (eg WHSE_TANTALIS.TA_CROWN_TENURES_SVW) failed to load. Load them with COPY, as geopandas.to_postgis already does for the rows with geometry, so postgres parses the text into column types.

Rows with no geometry were written with a plain DataFrame.to_sql insert.
Under psycopg 3, SQLAlchemy casts object columns to VARCHAR in that insert,
and postgres rejects VARCHAR values for DATE columns, so tables with
null-geometry rows and date columns (eg WHSE_TANTALIS.TA_CROWN_TENURES_SVW)
failed to load. Load them with COPY, as geopandas.to_postgis already does
for the rows with geometry, so postgres parses the text into column types.

Co-authored-by: Claude <noreply@anthropic.com>
@smnorris
smnorris merged commit 3dc81ec into main Nov 26, 2026
5 checks passed
@smnorris
smnorris deleted the fix-bc2pg-null-geom-copy branch November 26, 2026 22:29
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

Successfully merging this pull request may close these issues.

1 participant