Import wells from a table
A table of wells in a database your administrator approved becomes project wells in one journey: you say what the columns mean, review what will happen, and confirm. The rows that pass are kept as a copy with where they came from, each well is created and located, and the import is called finished only after the wells read back exactly through the project’s wells and the map feed QGIS reads. Nothing is kept before you confirm.
You need to be a project administrator, and the approved database must declare two things (see Connection administration):
- copy: that its rows may be kept, and for whom. Without it the import stops before anything is kept and says so.
- identifiers: which authority names its wells (for example
nlog). Without it the wells are named after the connection, and the review warns you.
In Workspace
Section titled “In Workspace”- Open Sources, browse your connection and choose Import wells beside the table.
- Say what the columns mean: the well identifier, the name, the X and Y columns and their coordinate reference (for example Amersfoort / RD New — metres). Choose Check all rows: every problem is listed beside the field it concerns, with how many rows and example values.
- Choose Save and import. The review says how many wells will be created, how many are already here, and lists every row that will be skipped with its reason (“A coordinate is missing”, “It has no identifier”) and every new well that has the name of one already here.
- Choose who else sees the copy and the wells (only people the approved database allows), then Confirm and import. Confirming records that you approved skipping the listed rows, and when.
- The progress bar counts the wells. The result says what was added, what was already here, what was skipped and why, and who approved it.
If the import is interrupted (a closed tab, a lost connection, a restarted server) it is Ready to resume: open Import wells on the same table again and choose Resume the import; it continues after the last committed row and never creates a well twice. Running the import again later creates nothing for rows already here.
The import keeps its mapping with itself. To make it the source’s mapping too, choose Use this mapping for the source on the result.
In Python
Section titled “In Python”Bring the connection, the table and the mapping. The mapping is the one you confirmed in Workspace (the review’s
Technical details shows it as JSON; save it as mapping.json):
import json
connection_id = "groningen-wells" # the connection (Sources, Technical details)table = "wells" # the table in that connectionmapping = json.load(open("mapping.json")) # what the columns mean, with the table's schema digestPreview first. Nothing is kept; the counts and every skipped row come back with their reasons:
from ophiolite.well_imports import words
imports = client.well_imports()review = imports.preview(connection_id, table, mapping)print(review["counts"])for row in review["skipped"]: print(row["row_key"] or "row %d" % row["ordinal"], words(row))Start the import you reviewed and run it to the end. The same command_id given again returns the same import,
so a lost answer is safe to repeat; run continues an interrupted import from any process:
record = imports.start(connection_id, table, mapping, preview_digest=review["preview_digest"], command_id="wells-import-1")done = imports.run(record["id"])print(done["words"], done["counts"]["created"], "added,", done["counts"]["already_here"], "already here")A second preview of the same table now creates nothing:
again = imports.preview(connection_id, table, mapping)print(again["counts"]["create"], "to create,", again["counts"]["already_here"], "already here")On the command line
Section titled “On the command line”ophiolite well-imports start --connection groningen-wells --table wells --mapping mapping.json --dry-runophiolite well-imports start --connection groningen-wells --table wells --mapping mapping.jsonophiolite well-imports listophiolite well-imports resume ID--dry-run prints the review and keeps nothing. start prints the import’s id before its first step, so an
interrupted import is resumed with resume ID from any process; a paused import exits with code 4 and its reason.
The wells are ordinary project wells: they appear in the Wells list and on the map, and QGIS opens them through the project’s map feed (see Wells on a map). People outside the audience you chose see neither the copy nor the wells.
