Posts

Showing posts with the label postgres

How to enable Postgres debugging

Image
 It's very simple. Just install the plugin with the following sentence: sudo apt install postgresql-12-pldebugger Next, edit /etc/postgresql/12/main/postgresql.conf and enable the plugin adding the following line: shared_preload_libraries = 'plugin_debugger' Now, you need to restart the postgres service sudo service postgres restart If you run PGAdmin4, now you can see the extension enabled Enjoy it!

HINT: No function matches the given name and argument types. You might need to add explicit type casts.

It is common when using different versions of PostgreSQL, the name of the functions can change their name. In my particular case, migrating from version 9 to 12, the error appears with the following function LINE 10: select ST_Line_Interpolate_Point(geom,distance) as ge...                     ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. Just change the function name ST_Line_Interpolate_Point to: ST_LineInterpolatePoint Enjoy!

QGIS: How to solver issues to import view layers from sql

If you want to add to QGIS sql sentences, an easy way is to create views. You only need to convert your sql sentence like: select geom from links to create or replace view v_links as select geom from links But, you probably see the following error: Layer is not valid: The layer dbname='' host=0.0.0.0 port=5432 user='' password='' sslmode=disable key='""' type=Point table="public"."v_links" (point) sql= is not a valid layer and can not be added to the map. Reason:  This issue is because an index doesn't exist for data To solve it, just create an index as follows: create or replace view v_links as select row_number() OVER (order by geom), geom from links Enjoy it!

ERROR (internal_error): Operation on mixed SRID geometries

I got this issue when I tried to optimize a pgsql code with postgis. See the following example that works with if you join it with other sentence: SELECT ST_SetSRID(ST_MakeLine(ST_MakePoint(4.51, 52.2), ST_MakePoint(23.42, 37.58)),4326) But, if you only replace ST_MakePoint by a geom selection you will have an error: SELECT ST_SetSRID(ST_MakeLine( (select point from nodes where name='3'), (select point from nodes where name='20')) ,4326) ERROR: Operation on mixed SRID geometries SQL state: XX000 To solve it just delete ST_SetSRID as follows: SELECT ST_MakeLine( (select point from nodes where name='3'), (select point from nodes where name='20')) Now it works Enjoy it!

How to install pgadmin4 in Ubuntu 18.10 throught apt

If you want to install pgadmin4, as the official site said, probably you can't do it if you have Ubuntu Cosmic. You need to add bionic repository, because in cosmic only pgadmin3 is available. Also, you need to specify if you are using 64 bits architecture. sudo apt-get install curl ca-certificates curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - sudo sh -c 'echo "ddeb [arch=amd64] http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main" > /etc/apt/sources.list.d/pgdg.list' sudo apt update sudo apt install pgadmin4 Enjoy it! Official site:  https://wiki.postgresql.org/wiki/Apt

How to install Qgis3.2 + Grass7 + PGAdmin4 + Postgres11 + Postgis2.5 in Ubuntu Bionic

To start the installation, you must to add the following lines to your /etc/apt/sources.list file: # qgis deb http://qgis.org/debian bionic main deb-src http://qgis.org/debian bionic main # pgadmin4 deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main 11 Now, you need to get the repositories keys with the following sentences: # qgis gpg --keyserver keyserver.ubuntu.com --recv CAEB3DC3BDF7FB45 gpg --export --armor CAEB3DC3BDF7FB45 | sudo apt-key add - # pgadmin4 wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - Now, proceed with installation: sudo apt-get update sudo apt-get upgrade sudo apt-get install postgresql postgresql-contrib postgresql-11-postgis-2.5-scripts pgadmin4 qgis python-qgis qgis-plugin-grass -y To configure postgres, we procced to create a database with a postgres user: sudo -u postgres createdb testing psql -d testing -c "create extension postgis" Probably you wi...

How to upgrade to Postgis 2.4.4

To upgrade postgis, you need download the tarball and compile it: wget https://download.osgeo.org/postgis/source/postgis-2.4.4.tar.gz tar xvzf postgis-2.4.4.tar.gz cd postgis-2.4.4 ./configure configure: WARNING:  --------- GEOS VERSION WARNING ------------  configure: WARNING:   You are building against GEOS 3.5.1  configure: WARNING:   To take advantage of all the features of  configure: WARNING:   this PostGIS version requires GEOS 3.7.0 or higher which is not out yet. configure: WARNING:   To take advantage of most of the features of this PostGIS configure: WARNING:   we recommend GEOS 3.6 or higher configure: WARNING:   You can download the latest versions from  configure: WARNING:   http://trac.osgeo.org/geos  We need to install the lastest geos version cd .. wget http://download.osgeo.org/geos/geos-3.7.0rc1.tar.bz2 tar xjvf geos-3.7.0rc1.tar.bz2 cd geos-3.7.0rc...

How to upgrade pgrouting to lastest version (2.6)

If you installed pgrouting from synaptic, probably you have pgrouting 2.4.2. To upgrade to the last version, download it from github: wget https://github.com/pgRouting/pgrouting/releases/download/v2.6.0/pgrouting-2.6.0.tar.gz tar xzvf pgrouting-2.6.0.tar.gz cd pgrouting-2.6.0 mkdir build cd build cmake .. -- POSTGRESQL_PG_CONFIG is /usr/bin/pg_config -- POSTGRESQL_EXECUTABLE is /usr/lib/postgresql/9.6/bin/postgres -- POSTGRESQL_VERSION_STRING in FindPostgreSQL.cmake is PostgreSQL 9.6.8 -- PostgreSQL not found. CMake Error at CMakeLists.txt:294 (message):    Please check your PostgreSQL installation. To solve it, you need to install postgres developer sudo apt-get install postgresql-server-dev-9.6 cmake .. Could not find the following Boost libraries:           boost_thread           boost_system -- CGAL not found. CMake Error at CMakeLists.txt:351 (message):    Please check your CGAL ...

Install metasploit 4.12.15 on Ubuntu 16.04 with postgres compatibility

If you want install metasploit on your distro, follow these steps: If you try Kali distribution, replace /opt by /usr/share and skip the git clone line sudo su   apt-get -y install build-essential zlib1g zlib1g-dev libxml2 libxml2-dev libxslt-dev locate libreadline6-dev libcurl4-openssl-dev git-core libssl-dev libyaml-dev openssl autoconf libtool ncurses-dev bison curl wget postgresql postgresql-contrib libpq-dev libapr1 libaprutil1 libsvn1 libpcap-dev libsqlite3-dev git-core postgresql curl ruby2.3 nmap gem   gem install wirble sqlite3 bundler   cd /opt   git clone https://github.com/rapid7/metasploit-framework.git   cd metasploit-framework   bundle install  If you run ./msfconsole maybe you won't connect to postgres msf > db_status [*] postgresql selected, no connection To solve it, you need to create an user an a database for postgres. I my case I name all values as msf4: sudo -s su postgres createuser msf4 -P Enter password ...