Is it is possible to convert query on postgresql database to geopackage file - postgresql

I am working on postgresql database with postgis.
I was generate csv file from the database which includes geo information but I need now to generate geopackage file instead.
I searched on this but I did not found any tools making something like that directly.
I know I can use gdal to convert from csv to geopackage file but I do not need to make that. I need to generate the geopackage file direct from the database.
Can anyone help me in that?
Thanks

gdal support also generate geopackage file from the table/view direct using command like the following:
ogr2ogr -f "GPKG" mynewfilename.gpkg \
PG:"host=localhost user=postgres dbname=postgres password=mypassword" "mytablename"

In theory: yes, it could be done. But in reality: it's almost impossible.
The geopackage file format is based on the SQLite one's. In PostgreSQL you can connect to different databases (in case of SQLite: to files) through foreign data wrappers. There is an SQLite foreign data wrapper, but it's only read-only. There is also a JDBC wrapper, which can support SQLite. But even if you can manage to write a new SQLite database file from PostgreSQL, you will need to study geopackage's internal format -- with just a "Coming soon" Implementation Guide (as of writing).

Related

Can I use a sql query or script to create format description files for multiple tables in an IBM DB2 for System I database?

I have an AS400 with an IBM DB2 database and I need to create a Format Description File (FDF) for each table in the DB. I can create the FDF file using the IBM Export tool but it will only create one file at a time which will take several days to complete. I have not found a way to create the files systematically using a tool or query. Is this possible or should this be done using scripting?
First of all, to correct a misunderstanding...
A Format Description File has nothing at all to do with the format of a Db2 table. It actually describes the format of the data in a stream file that you are uploading into the Db2 table. Sure you can turn on an option during the download from Db2 to create the FDF file, but it's still actually describing the data in the stream file you've just downloaded the data into. You can use the resulting FDF file to upload a modified version of the downloaded data or as the starting point for creating an FDF file that matches the actual data you want to upload.
Which explain why there's no built-in way to create an appropriate FDF file for every table on the system.
I question why you think you actually to generate an FDF file for every table.
As I recall, the format of the FDF (or it's newer variant FDFX) is pretty simple; it shouldn't be all that difficult to generate if you really wanted to. But I don't have one handy at the moment, and my Google-FU has failed me.

Is there a way to link (not import!) a dbf table into a PostgreSQL database?

I need to link an external dbf table into an existing PostgreSQL database. I managed to import that table into PostgreSQL but that creates a copy and therefor redundant data. The dbf table is the attribute table of a shapefile, but I don’t need the spatial aspect of it.
The exercise is part of a project to move data from an MS Access database to PostgreSQL hoping that the data then become accessible from QGIS. Th dbf table is at the moment linked into the MS Access database and used in queries (views) which I want to re-build in PostgreSQL.
I found lots of posts about importing dbf tables into but nothing which would work about linking a dbf table. The closest I got was the Foreign Data Wrapper, but I didn’t manage to use it for my purpose. I’m using PostgreSQL with pgAdmin 4.24.
Many thanks
The exercise is part of a project to move data from an MS Access database to PostgreSQL hoping that the data then become accessible from QGIS.
If you must use PostgreSQL in order to provide access to your spatial data from QGIS, I see no other option than importing the shapefile into PostgreSQL (PostGIS). If for whatever reason you do not need the geometries, you can drop the geometry column after importing the shapefile into the database:
ALTER TABLE table_name DROP COLUMN column_name;
Alternative scenario:
If we're talking about static shapefiles and you don't really need to use PostgreSQL, you can use GeoServer to publish this shapefile via Web Feature Service (WFS) - it is at least what I do in small projects. The easiest option would be to copy the shapefiles into a so called GeoServer Data Directory and publish them afterwards. After that you'd be able to access the data from QGIS using its WFS Client.

Seeding data into MongoDB database

I'm creating a MERN project and want a file to seed data into my database. Using sql I've done this by creating a seed file with a .db extension which I would then run as a script in my terminal. I am wondering how this is done for MongoDB and what file extension I should use, is this just a json file? I am also wondering what the proper way of doing this is. I was looking online but I see so many different ways that people do things so I'm just trying to figure out what the standard is.
Create each collection in a separate JSON or CSV file, and use mongoimport

DB2-clob data to PostgreSQL

We are planning to move data in DB2(28) to PostgreSQL(9.2).
We have already created database schema and tables in PostgreSQL. I am able to do data export from DB2 to csv format.
For importing data in PostgreSQL, the docs say "Copy command" which copies data from a file to the table.
In DB2, if data is of CLOB type, then separate file is created where CLOB data is kept. The main (data.csv) file contains references to CLOBs. How to import CLOB data in such cases?
I searched on net but could not find any opensource tool from PostgreSQL.
This is not a ready-to-use solution but may be a starting point. As far as I remember, DB2 is offering a ODBC interface. On the other hand on PostgreSQL you are able to "import" ODBC databases via Foreign data wrapper.The first step can be found at documentation. May be worth a try.

How to feed a DB PostgreSQL/PostGIS through data that are in Informix DB?

I do not have much experience in postgresql but would like some clues on how to do the following:
I intend to feed a DB PostgreSQL/PostGIS through data that are in Informix DB, which I have access via ODBC.
In short, I intend to do a "select" in Informix DB and be able to import that information directly into a DB PostgreSQL/PostGIS.
From what I understood it seems possible to do it via DBLink. Is that so?
Where can I get detailed information about this process?
I would suggest dump the data from whatever DB you have in text format like CSV, then use COPY command to load the data into PostgreSQL.