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 1haXrA-0008HY-RG for pgsql-general@arkaria.postgresql.org; Tue, 11 Jun 2019 03:53:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1haXr8-00069P-M3 for pgsql-general@arkaria.postgresql.org; Tue, 11 Jun 2019 03:53:54 +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 1haXr8-00069G-8h for pgsql-general@lists.postgresql.org; Tue, 11 Jun 2019 03:53:54 +0000 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1haXr5-0008PD-E5 for pgsql-general@postgresql.org; Tue, 11 Jun 2019 03:53:53 +0000 Received: by mail-pg1-x52f.google.com with SMTP id p10so295095pgn.1 for ; Mon, 10 Jun 2019 20:53:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=FAEmP/xKPFKbpfazCfiF9fqt63RYw+33dM1kdGqJfaM=; b=lj0fhvbkQsbrXz/MyajML2bGCbdSSc7BQh9eQ0HaX0oJ3m1q2d0swm/atrY+ijoKmM g6kI1Kc2a5mjfofy7dGtOBlk2EmkJGi+RyuocmO2qLxeh9tE0eMRs/WaCy2L8ZnEZBUm iCUUH/fWXr5rhMwC6PKw9pJ/1j31ZuEXAiipIaDdPtc+n99vFp1PzgQCApxuwhX+Bcld 0eSoXx3CJNLvvzFIqjiKRKbLP/YbWIexyBKA74att/O5/jDmySHSe/lJ0n5d0/1RtXps P9gDuPiuXSxdDFK9mqvzxclH1X//r7ehDaSinDzz2Cl7cWEnXEx77d25pRC30PDcFD71 6/BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=FAEmP/xKPFKbpfazCfiF9fqt63RYw+33dM1kdGqJfaM=; b=BFJX/G7f86EutlXczv0I2ve9dcIFQm8jDmp9ry/MS/cnTIFKscov/RjRVzvcVeivvU iVx+Hlw8VF+TIinq4S8uuwuYjLaXWddv+IT7qM3XbIqfR0AidlhP0kOTqHPQ718mqe4v Irsybv/4uI6SlVauEXeROjMPxk06qk52s6+UH9dRX9OCooKUjMwaL1jf3xZHq4HiJ0KV 1MjKHMQKvG8Wf2vPPWKg9OcSI9M3GwjF3OG7yXYNGI1abq9VD3t3iJ6IQ/WXttnyfX0Z frJ0KBRsecuFvHa9OloKAhlggsMoY8XWxG7IXmeO40CP7qMuOnM6mk88pEcOJQFG72jO 7n4A== X-Gm-Message-State: APjAAAV3qqAdhoMDKzHfNWatNEQYONGO4q2RtUm1fkf511Fxmpm14HuR t3LQ4Pmf+N2Nv0bdpNCRWus= X-Google-Smtp-Source: APXvYqwbInQm5oW9nPmeZHPFOCWYU9O4g2VtQi6AT+752gYeL2Kih/JBqfCW/9cUfHDp19UL43xPog== X-Received: by 2002:a63:144e:: with SMTP id 14mr18269240pgu.304.1560225228535; Mon, 10 Jun 2019 20:53:48 -0700 (PDT) Received: from [192.168.1.108] (c-73-63-59-118.hsd1.ut.comcast.net. [73.63.59.118]) by smtp.gmail.com with ESMTPSA id j64sm19655459pfb.126.2019.06.10.20.53.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Jun 2019 20:53:48 -0700 (PDT) From: Rob Sargent Message-Id: Content-Type: multipart/alternative; boundary="Apple-Mail=_3DEE0158-6C60-4064-9B15-A984D8E0B7B9" Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: Re: Inserting into the blob Date: Mon, 10 Jun 2019 21:53:46 -0600 In-Reply-To: Cc: Igor Korot , Adrian Klaver , "pgsql-general@postgresql.org" To: "David G. Johnston" References: <6cbb4f03-7c05-4473-330d-b220b0a9ec7b@aklaver.com> <84a73244-f26e-c2cc-4fac-81e6e39b7a42@aklaver.com> X-Mailer: Apple Mail (2.3445.104.11) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Apple-Mail=_3DEE0158-6C60-4064-9B15-A984D8E0B7B9 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 >=20 > >> 1) Are you really wanting to insert a file at a time at the psql = command > >> line? > >=20 > > Yes. > Gnarly. I suppose you could open the pdf in emacs and tell emacs to = NOT render it. Cut the entire buffer and paste it, properly quoted, into = your psql command line. But \lo stuff seems much more likely to work.=20 >=20 >=20 > This is what I've used for text: >=20 > \set file_content `cat './file.txt'` > SELECT:'file_content'; >=20 > For smallish files I'd probably just stick with the same theme but = encode the binary data as Base64 and then decode it into the bytea = field. >=20 > For not-so-small files probably better off storing the content = elsewhere and inserting location data into the database. >=20 > I have not yet had the desire to incorporate the large object API into = my designs. >=20 > David J. Yes if you=E2=80=99re comfortable managing the great leap of faith that = the file remains where it once claimed to be. And of course the other = camp must contend with what could be excessively large database data = directories. =20 --Apple-Mail=_3DEE0158-6C60-4064-9B15-A984D8E0B7B9 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8


>> 1) Are = you really wanting to insert a file at a time at the psql command
>> line?
>
> Yes.
Gnarly. I suppose you could open the pdf in emacs and tell emacs = to  NOT render it. Cut the entire buffer and paste it, properly = quoted, into your psql command line. But \lo stuff seems much more = likely to work.


This is what I've used = for text:

    \set file_content = `cat './file.txt'`
  =   SELECT:'file_content';

For smallish = files I'd probably just stick with the same theme but encode the binary = data as Base64 and then decode it into the bytea field.

For = not-so-small files probably better off storing the content elsewhere and = inserting location data into the database.

I have not yet had the = desire to incorporate the large object API into my designs.

David J.
Yes if you=E2=80=99re comfortable managing the great leap = of faith that the file remains where it once claimed to be. And of = course the other camp must contend with what could be excessively large = database data directories.
  

= --Apple-Mail=_3DEE0158-6C60-4064-9B15-A984D8E0B7B9--