-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Process SQL script (many SQL statements at once) #11279
Comments
I think that there are a few reasons to restrict it.
Fortunately there are alternatives. Not only the individual ogrinfo commands can be combined with a batch file, but there are also native database methods like using |
Hi @jratike80, thank you for your comment. Our often use case is running SQL from QGIS on GPKG file, where I would like to send several INSERT INTO, or UPDATE statements to change data. I am aware that it's possible (and I've done it before) to do this via But as I've said, it's not mandatory for us, and I fully understand if it doesn't fit well here, maybe a sentence in docs would be nice for users in future who might come up with this usecase. |
I thing that direct "insert into" does not fit well for what ogr2ogr and ogrinfo are designed for, but with SQL it is possible to do quite advanced things. Maybe you could create a temporary layer and then upsert https://gdal.org/en/latest/programs/ogr2ogr.html#cmdoption-ogr2ogr-upsert that layer into the main geopackage? I think that myself I would feel safer that way than doing it manually with a generic not GPKG-aware SQLite client. But inserts and updates should be safe and guarded by the triggers in GeoPackage. |
Feature description
Hi,
it would be very nice to process many SQL statements at once by loading SQL script from file.
Loading script from file is currently possible, but it processes only first SQL statement from loaded file.
Example (data - sql_script_example.zip):
Although
sql_script.sql
contains twoALTER TABLE
statements which should result adding two columns, currently only first one gets executed:If there is a valid reason why this is restricted to one statement only please close this feature request.
Additional context
No response
The text was updated successfully, but these errors were encountered: