GithubHelp home page GithubHelp logo

Comments (19)

amjith avatar amjith commented on July 27, 2024 1

This is now available in v1.0. Please upgrade.

pip install -U pgcli

from pgcli.

jackmaney avatar jackmaney commented on July 27, 2024

Ah, I think I see the issue. This error occurs when trying to run the following query:

SELECT d.datname as "Name",
       pg_catalog.pg_get_userbyid(d.datdba) as "Owner",
       pg_catalog.pg_encoding_to_char(d.encoding) as "Encoding",
       d.datcollate as "Collate",
       d.datctype as "Ctype",
       pg_catalog.array_to_string(d.datacl, E'\n') AS "Access privileges"
    FROM pg_catalog.pg_database d
    ORDER BY 1;

(which grabs metadata about databases). The datcollate column exists in that table in PostgreSQL 9.4, but not in PostgreSQL 8.2.15 (which is the psql version upon which Greenplum is built).

from pgcli.

jackmaney avatar jackmaney commented on July 27, 2024

The column seems to specify the LC_COLLATE configuration variable for a given database (which, along with the datctype column, specifies a locale for the database). Please let me know if I'm wrong, but I don't seem to see these columns used anywhere in the rest of the code. Are they necessary?

from pgcli.

amjith avatar amjith commented on July 27, 2024

@jackmaney You're right about the dependency of Postgres 9.4. In order to mimic the special back-slash commands from psql, I had to translate a giant chunk of C-code from psql source to Python.

I chose to stick with the minimum viable implementation that supported the latest PG (it was 9.2 at the time). I'll work on adding graceful fallback when an older version is use.

from pgcli.

jackmaney avatar jackmaney commented on July 27, 2024

Excellent. Thanks!

from pgcli.

gnmerritt avatar gnmerritt commented on July 27, 2024

Just wanted to chime in and mention that this unfortunately means pgcli won't work with Amazon's Redshift platform either. Would be happy to help try and add support if you'd like a hand and this issue isn't high priority

from pgcli.

amjith avatar amjith commented on July 27, 2024

I would love to get some help on this one.

The code for dealing with the special command can be found here: https://github.com/amjith/pgcli/blob/master/pgcli/packages/pgspecial.py#L76

The code is a translation of C code from psql source code.

You can see the conditions that check for postgres versions in psql code here:
https://github.com/postgres/postgres/blob/master/src/bin/psql/describe.c#L1252

I don't know how to detect the version of Postgres using psycopg2, but it might not be necessary to detect the version if it can be wrapped in a retry loop if a command fails.

from pgcli.

jackmaney avatar jackmaney commented on July 27, 2024

It's a fragile approach, but I know that select version(); produces a version string:

# select version();
                                                                              version
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
 PostgreSQL 9.4.0 on x86_64-apple-darwin, compiled by i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00), 64-bit
(1 row)

from pgcli.

amjith avatar amjith commented on July 27, 2024

Awesome! I forgot about select version().

I'll take fragile over non-existent. :)

from pgcli.

amjith avatar amjith commented on July 27, 2024

Aha. There is a way to find the server version using psycopg2. http://initd.org/psycopg/docs/connection.html#connection.server_version

:)

from pgcli.

jackmaney avatar jackmaney commented on July 27, 2024

Excellent. I'll try to scrape together a bit of time this weekend to give this a shot.

from pgcli.

hollobon avatar hollobon commented on July 27, 2024

Anyone working on this? Considering doing this myself but I don't want to duplicate effort.

from pgcli.

amjith avatar amjith commented on July 27, 2024

@hollobon No one is working on it as far as I know. That's why I put a back_burner label on it. Because I couldn't find time to work on it.

If you need some help getting started please feel free to leave a comment.

from pgcli.

conorccamp avatar conorccamp commented on July 27, 2024

I got this connected to Redshift (PostgreSQL 8.0.2) and am currently working on getting the meta commands working. I'll make a pull request this weekend but I'll need some help getting my code cleaned up since I'm still very much a beginner python developer.

from pgcli.

amelio-vazquez-reina avatar amelio-vazquez-reina commented on July 27, 2024

Great news. 👍 Happy to help with beta testing or in any other way possible.

from pgcli.

amjith avatar amjith commented on July 27, 2024

I'll be happy to help clean up the code. Feel free to open the PR.

The meta commands (or back-slash) command can be challenging to implement. So I'll be fine if you want to do that as a separate PR. :)

Thank you for taking a stab at it. :)

from pgcli.

hollobon avatar hollobon commented on July 27, 2024

I'm planning to translate the version-dependent bits from psql (mainly in src/tools/bin/psql/describe.c). Hoping to make a start tonight / tomorrow, but don't want to tread on toes so I'll hold off if others doing the same.

from pgcli.

jklukas avatar jklukas commented on July 27, 2024

I'd also like to use pgcli with Redshift, so +1 to this effort. I'm happy to participate in code review when a PR comes together.

from pgcli.

rakeshsingh avatar rakeshsingh commented on July 27, 2024

+1
Using pgcli with Redshift, and getting the same error

from pgcli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.