Can Awk directly interact with some RDBMS engine (that is, within
'BEGIN{}')?
On 2/3/2024 1:25 am, Janis Papanagnou wrote:
I suppose it's the only solution, unless you extend Awk's syntax to SQLconnect some RDBMS. :)
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.
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. :)
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 ""
}
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?
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 498 |
Nodes: | 16 (0 / 16) |
Uptime: | 68:26:39 |
Calls: | 9,814 |
Calls today: | 2 |
Files: | 13,755 |
Messages: | 6,189,407 |