Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gyr3I-0000Kj-DG for pgsql-general@arkaria.postgresql.org; Wed, 27 Feb 2019 04:42:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gyr3H-00086m-6d for pgsql-general@arkaria.postgresql.org; Wed, 27 Feb 2019 04:42:39 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gyr3G-00086Y-Si for pgsql-general@lists.postgresql.org; Wed, 27 Feb 2019 04:42:38 +0000 Received: from mail-ot1-x344.google.com ([2607:f8b0:4864:20::344]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gyr3E-0005e0-Kk for pgsql-general@lists.postgresql.org; Wed, 27 Feb 2019 04:42:38 +0000 Received: by mail-ot1-x344.google.com with SMTP id e15so3680833otk.6 for ; Tue, 26 Feb 2019 20:42:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=QxPRVFQE6IcOr14ioxPjMSITVl92An/c35AB/1id48c=; b=NRDXmpkQK8UlnoSGZIdybBpL50TQYT/dH577/hl3zegjJkCZotFI1iqTBlQhrASgtB AsWdFR/fS72kqbpjUCh5YoY2Z21DhlYO5YBrNuzTDT3nebI29rqYaTXJXcHqCbJQCscw UgoEv2hKfiliUedHfmckigsw9V0frQPhk6TJZjWo8SQiSSP3HQSH0P97D6pTi0wFWxKt RcV9cRHAff+LamLIDhMjHQgmlw1OfSNYwPKjRpV21yWacuexylUjkIXD34BCgjccYboP lUdHBONx2PIj5VNOqK1+UpUnGxK1cx5UgaLGljUNQ2Gl8R7jN3hiylXn3IGjMXNV4ULg DcEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=QxPRVFQE6IcOr14ioxPjMSITVl92An/c35AB/1id48c=; b=kcerWk8/8MVUMkcjOYFtNlDes1XNHCnHmM4kxEkZ5/+jKD/DDUo1hnEj9dqrx7y+zK ZmpPm9MY23ao8nyUHWSFZH/J5U/ROQf3XS0CaOagI6f8R4D3LsUYNNFLKuwAo7Hv8rZw Maur4J4eXyn25PRyIaUO3C8x5YVyslHCm7ug8MWyvhbBR3vxxfLXICzN2NZHySzYZNzo wz6FQxAuQh9OOebNI56uKSw60sJ0Gz3mIvRYa8pA997jqZv4WiZqNCro6MIL8PimmkQY earCpQR5JWBzr8xxozbYOt08xZ0rCB8OIueIxqYS3PLFZ48oL1lWDwrntlRa2YHL2DTd He6w== X-Gm-Message-State: APjAAAUy2wgNcT3v46kmFiFsrEEbqG01pOWSyQEo8x0xwMf4X0bj5EYW HKJmd7SHXnCDXheCwgbY318iuZM5 X-Google-Smtp-Source: AHgI3IYQuKyecyl7+wgC2lnEdWHPG34V34dPo7k7SsIVD2c/rLZbT8KlnkcVn6e/V8b36D02o3k5Sw== X-Received: by 2002:a05:6830:19:: with SMTP id c25mr932067otp.79.1551242553972; Tue, 26 Feb 2019 20:42:33 -0800 (PST) Received: from [192.168.1.10] (ip70-171-116-89.no.no.cox.net. [70.171.116.89]) by smtp.googlemail.com with ESMTPSA id h138sm6776130oic.8.2019.02.26.20.42.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Feb 2019 20:42:33 -0800 (PST) Subject: Re: crosstab function To: pgsql-general@lists.postgresql.org References: <3B0E0069-18FC-476D-90A1-5201891AA52C@northwestern.edu> From: Ron Message-ID: Date: Tue, 26 Feb 2019 22:42:32 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <3B0E0069-18FC-476D-90A1-5201891AA52C@northwestern.edu> Content-Type: multipart/alternative; boundary="------------2E9A3A92FF611B5400307C07" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------2E9A3A92FF611B5400307C07 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 2/26/19 7:51 PM, Martin Mueller wrote: > > I run Postgres 10.5.  I understand that there is something called > tablefunc and it includes a crosstab function. On Stack Overflow I learn > that you import this function. But from where and how?  The Postgres > documentation is quite clear and intelligible to a retired English > professor like me, but there is nothing in the Postgres documentation > about how to do the import, and a search for ‘import modules’ yields nothing. > > I tried to emulate a Stack overflow query that does what I want to do, but > got an error message saying that the crosstab function doesn’t exist. I tried > > CREATEEXTENSION IFNOTEXISTStablefunc; > > but it did nothing. It doesn’t seem to work  as import statements in Python do > Extensions are short bits of sql that create functions for you, and point to "shared object" executable files.  Quite literally, it's extending postgres. Thus, the actual executable file needs to be somewhere on the computer's hard drive (specifically, where Postgres expects it to be for your OS). In the Linux world, for example, there's typically a package you install named something like postgresql96-contrib-9.6.9-blahblah.rpm.  You'd install that using the OS' package manager, restart postgres and then CREATE EXTENSION should work. You'll have to determine whether PostgreApp comes with "contribs". If not, you'll have to use another source for Pg, like MacPorts. -- Angular momentum makes the world go 'round. --------------2E9A3A92FF611B5400307C07 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit On 2/26/19 7:51 PM, Martin Mueller wrote:

I run Postgres 10.5.  I understand that there is something called tablefunc and it includes a crosstab function. On Stack Overflow I learn that you import this function. But from where and how?  The Postgres documentation is quite clear and intelligible to a retired English professor like me, but there is nothing in the Postgres documentation about how to do the import, and a search for ‘import modules’ yields nothing.

 

I tried to emulate a Stack overflow query that does what I want to do, but got an error message saying that the crosstab function doesn’t exist. I tried

 

CREATE EXTENSION IF NOT EXISTS tablefunc;

 

but it did nothing. It doesn’t seem to work  as import statements in Python do


Extensions are short bits of sql that create functions for you, and point to "shared object" executable files.  Quite literally, it's extending postgres.

Thus, the actual executable file needs to be somewhere on the computer's hard drive (specifically, where Postgres expects it to be for your OS).

In the Linux world, for example, there's typically a package you install named something like postgresql96-contrib-9.6.9-blahblah.rpm.  You'd install that using the OS' package manager, restart postgres and then CREATE EXTENSION should work.

You'll have to determine whether PostgreApp comes with "contribs".  If not, you'll have to use another source for Pg, like MacPorts.

--
Angular momentum makes the world go 'round.
--------------2E9A3A92FF611B5400307C07--