Showing posts with label postgres. Show all posts
Showing posts with label postgres. Show all posts

Monday, January 30, 2017

psql: symbol lookup error: psql: undefined symbol: PQsslInUse

so, i have a postgres 9.4 on a fedora 23 when fedora 25 was released. i tend to keep the second recent version of OS, so i upgraded to fedora 24 via dnf. after upgrade, my rails apps that use my postgres worked okay. that means everything is running. but when i had to connect to postgres through console, i got this:


rather than committing myself to solving it, i made do with using rails console to access my database.

a friend upgraded his ubuntu 14 to ubuntu 16 and had his rails apps set up. his postgres was working as it should. so, it's time i had to make my console access to work again.

i checked postgresql packages installed on my box, and got these:


i uninstalled postgresql 9.5 installations done by my os upgrade and left these packages:


then i got a command not found when i run psql, i searched the psql command and created a sym link to /bin/ as so:



apir! psql through console is back yep, t'was just a postgresql client-server version mismatch :)

Thursday, October 27, 2011

gdal: update supported formats

to update gdal's supported formats, extract compressed source then configure with support options. i use the options below which include support for postgresql and mysql
./configure --with-jpeg --with-gd --with-freetype --with-png --with-ogr --with-proj --with-gdal --with-httpd=/usr/local/apache2 --with-tiff --with-wfs --with-wcs --with-threads --with-wmsclient --with-wfsclient --with-geos=/usr/local/bin/geos-config --with-postgis --enable-debug --with-pg=/usr/local/pgsql/bin/pg_config --with-gif --with-mysql --with-php-- --with-libtiff --with-static-proj4=/usr/local/bin

to check gdal's supported formats
# ogrinfo --formats
Supported Formats:
  -> "ESRI Shapefile" (read/write)
  -> "MapInfo File" (read/write)
  -> "UK .NTF" (readonly)
  -> "SDTS" (readonly)
  -> "TIGER" (read/write)
  -> "S57" (read/write)
  -> "DGN" (read/write)
  -> "VRT" (readonly)
  -> "REC" (readonly)
  -> "Memory" (read/write)
  -> "BNA" (read/write)
  -> "CSV" (read/write)
  -> "GML" (read/write)
  -> "GPX" (read/write)
  -> "KML" (read/write)
  -> "GeoJSON" (read/write)
  -> "GMT" (read/write)
  -> "PostgreSQL" (read/write)
  -> "MySQL" (read/write)
  -> "AVCBin" (readonly)


Thursday, October 13, 2011

postgis, postgres: geometry columns

# create table (with oid option) and add needed columns
CREATE TABLE mypoints(name varchar(255), x decimal(20,8), y decimal(20,8)) with oids;

# populate columns from source text file
COPY mypoints FROM '/data/dlmysqldata/mypoints.txt';

# create geometry column named mygeom
SELECT AddGeometryColumn('public', 'mypoints', 'mygeom', 4326, 'POINT', 2);

# update  geometry column with point geometry from columns
UPDATE mypoints set mygeom=ST_GeomFromText('POINT(x y)', 4326);
ERROR:  parse error - invalid geometry

# hmmm...
UPDATE mypoints set mygeom=ST_GeomFromText('POINT(-71.0891380310059 42.3123226165771)', 4326);
# but this works!

UPDATE mypoints set mygeom=ST_GeomFromText('POINT(' || x || ' ' || y || ')', 4326);
# aha!

# create geography table; replace with correct SRID
ALTER TABLE mypoints add mygeog geography(POINT,4326);
UPDATE mypoints set mygeog=ST_GeomFromText('SRID:4326;POINT(' || x || ' ' || y || ')');

# i now get column "oid" does not exist. try to recreate table with oid

# create line table
CREATE TABLE mylines(name varchar(255), id varchar(255), x1 decimal(20,8), y1 decimal(20,8), x2 decimal(20,8), y2 decimal(20,8)) with oids;
SELECT AddGeometryColumn('public', 'mylines', 'mygeom', 4326, 'LINESTRING', 2);
UPDATE mylines set mygeom=ST_GeomFromText('LINESTRING(' || x1 || ' ' || y1 || ',' || x2 || ' ' || y2 || ')', 4326);
GRANT all ON TABLE mylines TO devuser;

# create polygon table
create table mypolys(name varchar(255), id varchar(255), x1 decimal(20,8), y1 decimal(20,8), x2 decimal(20,8), y2 decimal(20,8), x3 decimal(20,8), y3 decimal(20,8), x4 decimal(20,8), y4 decimal(20,8)) with oids;
SELECT AddGeometryColumn('public', 'mypolys', 'mygeom', 4326, 'POLYGON', 2);
UPDATE mypolys set mygeom=ST_GeomFromText('POLYGON((' || x1 || ' ' || y1 || ',' || x2 || ' ' || y2 || ',' || x3 || ' ' || y3 || ',' || x4 || ' ' || y4 || '))', 4326);
GRANT all ON TABLE mypolys TO devuser;

# be sure to grant access
# connect to your db by using \c <dbname>
# - for db access
GRANT all ON database spatial_test TO devuser;
# - for table access
GRANT all ON TABLE mypoints TO devuser;
# - for geom access
GRANT all ON TABLE geometry_columns TO devuser;
# - for spatial access
GRANT all ON table spatial_ref_sys TO devuser;

Friday, August 12, 2011

coldfusion: connecting with postgres as datasource

to setup postgres as coldfusion datasource:

1. download jdbc* driver and place into coldfusion's java lib directory
    (/opt/coldfusionmx/lib or <coldfusion path>/lib)

2. restart cf

3. use dsn details below
    Field Description 
    JDBC URL - jdbc:postgresql://<pgsqlDbHost>/<databaseName> 
    Driver Class - org.postgresql.Driver 
    Driver Name (Optional) (The name of the driver  )
    Username (ColdFusion user account on the database server)
    Password (Password for the user account on the database server )

4. configure postgres to accept tcp/ip connections because java uses tcp/ip connections

    edit postgresql.conf
        set hba_file = '/usr/local/pgsql/data/pg_hba.conf'
        set listen_address = 'localhost,192.168.1.12,etc'

    edit pg_hba.conf, add
        host    all             all     192.168.1.12/32         trust
        host    all             all     192.168.1.13/32         trust
    etc

* using jdbc3

SSH : No matching host key type found. Their offer: ssh-rsa,ssh-dss

Got this while connecting to my mikrotik router via ssh   Unable to negotiate with <ip address> port <ssh port>: no matching hos...