Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Chemistry professors never die, they just fail to react.


devel / comp.lang.awk / Re: Awk and RDBMS

SubjectAuthor
* Awk and RDBMSMr. Man-wai Chang
+* Re: Awk and RDBMSJanis Papanagnou
|`* Re: Awk and RDBMSMr. Man-wai Chang
| `* Re: Awk and RDBMSJanis Papanagnou
|  `- Re: Awk and RDBMSMr. Man-wai Chang
`* Re: Awk and RDBMSArti F. Idiot
 +- Re: Awk and RDBMSMr. Man-wai Chang
 `* Re: Awk and RDBMSGrant Taylor
  `- Re: Awk and RDBMSKaz Kylheku

1
Awk and RDBMS

<ursvpa$1an2m$4@toylet.eternal-september.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1781&group=comp.lang.awk#1781

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!news.nntp4.net!news.gegeweb.eu!gegeweb.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!toylet.eternal-september.org!.POSTED!not-for-mail
From: toylet.toylet@gmail.com (Mr. Man-wai Chang)
Newsgroups: comp.lang.awk
Subject: Awk and RDBMS
Date: Sat, 2 Mar 2024 00:29:29 +0800
Organization: A noiseless patient Spider
Lines: 5
Message-ID: <ursvpa$1an2m$4@toylet.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 1 Mar 2024 16:29:30 -0000 (UTC)
Injection-Info: toylet.eternal-september.org; posting-host="a5dfc74f3d92357c9c3e5d43cc47f31b";
logging-data="1399894"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/XxfFXdqBPMOVyN62fVcKD"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:gDy8uQ/RC+6Pa/7E/k6UATg9jf4=
Content-Language: en-US
 by: Mr. Man-wai Chang - Fri, 1 Mar 2024 16:29 UTC

Can Awk directly interact with some RDBMS engine (that is, within
'BEGIN{}')?

I haven't done a Google Search yet. Is looking for a direct answer. :)

Re: Awk and RDBMS

<urt326$1bi7n$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1783&group=comp.lang.awk#1783

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.lang.awk
Subject: Re: Awk and RDBMS
Date: Fri, 1 Mar 2024 18:25:26 +0100
Organization: A noiseless patient Spider
Lines: 13
Message-ID: <urt326$1bi7n$1@dont-email.me>
References: <ursvpa$1an2m$4@toylet.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 1 Mar 2024 17:25:26 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="d63b5913b208007a66e59d1f1c95c79a";
logging-data="1427703"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/90q5934X+Ks8gi3m9/aaz"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:/YA3QFBUBiZ3VoEF8iDYAGUI+p0=
In-Reply-To: <ursvpa$1an2m$4@toylet.eternal-september.org>
 by: Janis Papanagnou - Fri, 1 Mar 2024 17:25 UTC

On 01.03.2024 17:29, Mr. Man-wai Chang wrote:
>
> Can Awk directly interact with some RDBMS engine (that is, within
> 'BEGIN{}')?

It depends on the interface the RDBMS provides.

What you can do with GNU awk is, for example, to create a co-process
and send requests to that co-process and intercept its replies to
process them.

Janis

Re: Awk and RDBMS

<us1im1$2embg$1@toylet.eternal-september.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1789&group=comp.lang.awk#1789

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!toylet.eternal-september.org!.POSTED.110235006069.ctinets.com!not-for-mail
From: toylet.toylet@gmail.com (Mr. Man-wai Chang)
Newsgroups: comp.lang.awk
Subject: Re: Awk and RDBMS
Date: Sun, 3 Mar 2024 18:16:32 +0800
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <us1im1$2embg$1@toylet.eternal-september.org>
References: <ursvpa$1an2m$4@toylet.eternal-september.org>
<urt326$1bi7n$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 3 Mar 2024 10:16:33 -0000 (UTC)
Injection-Info: toylet.eternal-september.org; posting-host="110235006069.ctinets.com:110.235.6.69";
logging-data="2578800"; mail-complaints-to="abuse@eternal-september.org"
User-Agent: Mozilla Thunderbird
In-Reply-To: <urt326$1bi7n$1@dont-email.me>
Content-Language: en-US
 by: Mr. Man-wai Chang - Sun, 3 Mar 2024 10:16 UTC

On 2/3/2024 1:25 am, Janis Papanagnou wrote:
>
> It depends on the interface the RDBMS provides.
>
> What you can do with GNU awk is, for example, to create a co-process
> and send requests to that co-process and intercept its replies to
> process them.
I suppose it's the only solution, unless you extend Awk's syntax to
SQLconnect some RDBMS. :)

Re: Awk and RDBMS

<us24ua$2i9t8$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1791&group=comp.lang.awk#1791

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED.ppp-212-114-181-192.dynamic.mnet-online.de!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.lang.awk
Subject: Re: Awk and RDBMS
Date: Sun, 3 Mar 2024 16:28:09 +0100
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <us24ua$2i9t8$1@dont-email.me>
References: <ursvpa$1an2m$4@toylet.eternal-september.org>
<urt326$1bi7n$1@dont-email.me> <us1im1$2embg$1@toylet.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 3 Mar 2024 15:28:10 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="ppp-212-114-181-192.dynamic.mnet-online.de:212.114.181.192";
logging-data="2697128"; mail-complaints-to="abuse@eternal-september.org"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
In-Reply-To: <us1im1$2embg$1@toylet.eternal-september.org>
 by: Janis Papanagnou - Sun, 3 Mar 2024 15:28 UTC

On 03.03.2024 11:16, Mr. Man-wai Chang wrote:
> On 2/3/2024 1:25 am, Janis Papanagnou wrote:
>>
>> It depends on the interface the RDBMS provides.
>>
>> What you can do with GNU awk is, for example, to create a co-process
>> and send requests to that co-process and intercept its replies to
>> process them.
> I suppose it's the only solution, unless you extend Awk's syntax to
> SQLconnect some RDBMS. :)

Well, in the past there was xgawk that supported database handling.
This feature is now available in GNU Awk as part of its extension
library. You can handle PostgreSQL with it. But since I have never
used it myself you have to look up the details yourself. (Or maybe
there's someone around here who has experiences with the extension
or can answer any specific questions.)

Janis

Re: Awk and RDBMS

<us2t3p$2475$1@nnrp.usenet.blueworldhosting.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1793&group=comp.lang.awk#1793

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!nnrp.usenet.blueworldhosting.com!.POSTED!not-for-mail
From: addr@is.invalid (Arti F. Idiot)
Newsgroups: comp.lang.awk
Subject: Re: Awk and RDBMS
Date: Sun, 3 Mar 2024 15:20:41 -0700
Organization: Anarchists of America
Message-ID: <us2t3p$2475$1@nnrp.usenet.blueworldhosting.com>
References: <ursvpa$1an2m$4@toylet.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 3 Mar 2024 22:20:41 -0000 (UTC)
Injection-Info: nnrp.usenet.blueworldhosting.com;
logging-data="69861"; mail-complaints-to="usenet@blueworldhosting.com"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:QXU3R9uKn4wy9KCqwyZU4NgQ6Z0= sha256:W2GEd7Yuz4InuyqbaNcamclQ4uUJfFkhK41MCAECZPE=
sha1:1fLsL4mIiYMKCTAnRVOsXiI8PBo= sha256:Fmms9kyxZsCe6eSEVBJPKi9oKPZLHLE4caBIUhvUe/c=
Content-Language: en-US
In-Reply-To: <ursvpa$1an2m$4@toylet.eternal-september.org>
 by: Arti F. Idiot - Sun, 3 Mar 2024 22:20 UTC

On 3/1/24 9:29 AM, Mr. Man-wai Chang wrote:
>
> Can Awk directly interact with some RDBMS engine (that is, within
> 'BEGIN{}')?
>
> I haven't done a Google Search yet. Is looking for a direct answer. :)

I *think* most SQL type DBs have CLI interaction capabilities.

A SQLite3 example; 'csv' used for DB output mode since it's easy to run
split() on and several awks now have native CSV support:

--
$ sqlite3 -header -column site.db 'select * from site'
Station SSID CHAN
---------- ---------- ----------
1 CIA 9
2 FBI 11
3 NSA 1
4 DOD 10

$ cat site.awk
BEGIN {
DBfile = "./site.db"
CMD = "sqlite3 -csv " DBfile " \"" ARGV[1] "\""
while (CMD | getline == 1) arr[++cnt] = $0
close(CMD)
for (i=1; i<=cnt; i++) printf "arr[%d] = %s\n", i, arr[i]
print ""
}

$ nawk -f site.awk 'select * from site'
arr[1] = 1,CIA,9
arr[2] = 2,FBI,11
arr[3] = 3,NSA,1
arr[4] = 4,DOD,10

$ nawk -f site.awk 'select SSID from site'
arr[1] = CIA
arr[2] = FBI
arr[3] = NSA
arr[4] = DOD

--

This is just read-only of course; would need to use gawk for fancier things.

Re: Awk and RDBMS

<us4hvs$35jha$2@toylet.eternal-september.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1795&group=comp.lang.awk#1795

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!toylet.eternal-september.org!.POSTED!not-for-mail
From: toylet.toylet@gmail.com (Mr. Man-wai Chang)
Newsgroups: comp.lang.awk
Subject: Re: Awk and RDBMS
Date: Mon, 4 Mar 2024 21:23:07 +0800
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <us4hvs$35jha$2@toylet.eternal-september.org>
References: <ursvpa$1an2m$4@toylet.eternal-september.org>
<urt326$1bi7n$1@dont-email.me> <us1im1$2embg$1@toylet.eternal-september.org>
<us24ua$2i9t8$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 4 Mar 2024 13:23:08 -0000 (UTC)
Injection-Info: toylet.eternal-september.org; posting-host="1dc1657cfb18c126bb5f45a89d37376d";
logging-data="3329578"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+1QJ2g7Xu5jbHyTNotG+VH"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:0FeBr9JTt5AhstzKat1X7Yjobtk=
In-Reply-To: <us24ua$2i9t8$1@dont-email.me>
Content-Language: en-US
 by: Mr. Man-wai Chang - Mon, 4 Mar 2024 13:23 UTC

On 3/3/2024 11:28 pm, Janis Papanagnou wrote:
>
> Well, in the past there was xgawk that supported database handling.
> This feature is now available in GNU Awk as part of its extension
> library. You can handle PostgreSQL with it. But since I have never
> used it myself you have to look up the details yourself. (Or maybe
> there's someone around here who has experiences with the extension
> or can answer any specific questions.)

Thanks!

Re: Awk and RDBMS

<us4i18$35jha$3@toylet.eternal-september.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1796&group=comp.lang.awk#1796

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!nntp.comgw.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!toylet.eternal-september.org!.POSTED!not-for-mail
From: toylet.toylet@gmail.com (Mr. Man-wai Chang)
Newsgroups: comp.lang.awk
Subject: Re: Awk and RDBMS
Date: Mon, 4 Mar 2024 21:23:51 +0800
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <us4i18$35jha$3@toylet.eternal-september.org>
References: <ursvpa$1an2m$4@toylet.eternal-september.org>
<us2t3p$2475$1@nnrp.usenet.blueworldhosting.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 4 Mar 2024 13:23:52 -0000 (UTC)
Injection-Info: toylet.eternal-september.org; posting-host="1dc1657cfb18c126bb5f45a89d37376d";
logging-data="3329578"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18jfIl1bGxJcASLhcAcIdPg"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:qXlOk2CUWuNCJSEdP70T2xKNY1Y=
In-Reply-To: <us2t3p$2475$1@nnrp.usenet.blueworldhosting.com>
Content-Language: en-US
 by: Mr. Man-wai Chang - Mon, 4 Mar 2024 13:23 UTC

On 4/3/2024 6:20 am, Arti F. Idiot wrote:
> On 3/1/24 9:29 AM, Mr. Man-wai Chang wrote:
>>
>> Can Awk directly interact with some RDBMS engine (that is, within
>> 'BEGIN{}')?
>>
>> I haven't done a Google Search yet. Is looking for a direct answer. :)
>
> I *think* most SQL type DBs have CLI interaction capabilities.
>
> A SQLite3 example; 'csv' used for DB output mode since it's easy to run
> split() on and several awks now have native CSV support:
> ....

Thank you for putting up an example!

Re: Awk and RDBMS

<us4u1s$50t$2@tncsrv09.home.tnetconsulting.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1798&group=comp.lang.awk#1798

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!tncsrv06.tnetconsulting.net!tncsrv09.home.tnetconsulting.net!.POSTED.omega.home.tnetconsulting.net!not-for-mail
From: gtaylor@tnetconsulting.net (Grant Taylor)
Newsgroups: comp.lang.awk
Subject: Re: Awk and RDBMS
Date: Mon, 4 Mar 2024 10:49:00 -0600
Organization: TNet Consulting
Message-ID: <us4u1s$50t$2@tncsrv09.home.tnetconsulting.net>
References: <ursvpa$1an2m$4@toylet.eternal-september.org>
<us2t3p$2475$1@nnrp.usenet.blueworldhosting.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 4 Mar 2024 16:49:00 -0000 (UTC)
Injection-Info: tncsrv09.home.tnetconsulting.net; posting-host="omega.home.tnetconsulting.net:198.18.1.140";
logging-data="5149"; mail-complaints-to="newsmaster@tnetconsulting.net"
User-Agent: Mozilla Thunderbird
Content-Language: en-US
In-Reply-To: <us2t3p$2475$1@nnrp.usenet.blueworldhosting.com>
 by: Grant Taylor - Mon, 4 Mar 2024 16:49 UTC

On 3/3/24 16:20, Arti F. Idiot wrote:
> BEGIN {
>   DBfile = "./site.db"
>   CMD = "sqlite3 -csv " DBfile " \"" ARGV[1] "\""
>   while (CMD | getline == 1) arr[++cnt] = $0
>   close(CMD)
>   for (i=1; i<=cnt; i++) printf "arr[%d] = %s\n", i, arr[i]
>   print ""
> }

Would someone please help me understand why you'd want to have the
sqlite3 (et al.) inside of awk (in the BEGIN{...}) verses having sqlite3
outside of awk and piping the output from sqlite3's STDOUT into awk's STDIN?

sqlite3 ... | awk ...

--
Grant. . . .

Re: Awk and RDBMS

<20240304090646.580@kylheku.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1799&group=comp.lang.awk#1799

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 433-929-6894@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.awk
Subject: Re: Awk and RDBMS
Date: Mon, 4 Mar 2024 17:10:26 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <20240304090646.580@kylheku.com>
References: <ursvpa$1an2m$4@toylet.eternal-september.org>
<us2t3p$2475$1@nnrp.usenet.blueworldhosting.com>
<us4u1s$50t$2@tncsrv09.home.tnetconsulting.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 4 Mar 2024 17:10:26 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="e3728d8dcd2e7deeba330e9e082a4102";
logging-data="3427589"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18cMJTPSGVmTyya14+HnQ/jA2WDiLjS+rI="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:QC6NLfqfZ2XHaotPmFhdKW1ljQI=
 by: Kaz Kylheku - Mon, 4 Mar 2024 17:10 UTC

On 2024-03-04, Grant Taylor <gtaylor@tnetconsulting.net> wrote:
> On 3/3/24 16:20, Arti F. Idiot wrote:
>> BEGIN {
>>   DBfile = "./site.db"
>>   CMD = "sqlite3 -csv " DBfile " \"" ARGV[1] "\""
>>   while (CMD | getline == 1) arr[++cnt] = $0
>>   close(CMD)
>>   for (i=1; i<=cnt; i++) printf "arr[%d] = %s\n", i, arr[i]
>>   print ""
>> }
>
> Would someone please help me understand why you'd want to have the
> sqlite3 (et al.) inside of awk (in the BEGIN{...}) verses having sqlite3
> outside of awk and piping the output from sqlite3's STDOUT into awk's STDIN?

1. You could just have a #!/usr/bin/awk -f script instead of
a #!/bin/sh script that calls awk.

2. That script's standard input is available for other use. For
it could process the sqlite file to populate the array in the
above way, and then process standard input with the help of that
array.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor