Awk.Info

"Cause a little auk awk
goes a long way."

About awk.info
 »  table of contents
 »  featured topics
 »  page tags


About Awk
 »  advocacy
 »  learning
 »  history
 »  Wikipedia entry
 »  mascot
Implementations
 »  Awk (rarely used)
 »  Nawk (the-one-true, old)
 »  Gawk (widely used)
 »  Mawk
 »  Xgawk (gawk + xml + ...)
 »  Spawk (SQL + awk)
 »  Jawk (Awk in Java JVM)
 »  QTawk (extensions to gawk)
 »  Runawk (a runtime tool)
 »  platform support
Coding
 »  one-liners
 »  ten-liners
 »  tips
 »  the Awk 100
Community
 »  read our blog
 »  read/write the awk wiki
 »  discussion news group

Libraries
 »  Gawk
 »  Xgawk
 »  the Lawker library
Online doc
 »  reference card
 »  cheat sheet
 »  manual pages
 »  FAQ

Reading
 »  articles
 »  books:

WHAT'S NEW?

Mar 01: Michael Sanders demos an X-windows GUI for AWK.

Mar 01: Awk100#24: A. Lahm and E. de Rinaldis' patent search, in AWK

Feb 28: Tim Menzies asks this community to write an AWK cookbook.

Feb 28: Arnold Robbins announces a new debugger for GAWK.

Feb 28: Awk100#23: Premysl Janouch offers a IRC bot, In AWK

Feb 28: Updated: the AWK FAQ

Feb 28: Tim Menzies offers a tiny content management system, in Awk.

Jan 31: Comment system added to awk.info. For example, see discussion bottom of ?keys2awk

Jan 31: Martin Cohen shows that Gawk can handle massively long strings (300 million characters).

Jan 31: The AWK FAQ is being updated. For comments/ corrections/ extensions, please mail tim@menzies.us

Jan 31: Martin Cohen finds Awk on the Android platform.

Jan 31: Aleksey Cheusov released a new version of runawk.

Jan 31: Hirofumi Saito contributes a candidate Awk mascot.

Jan 31: Michael Sanders shows how to quickly build an AWK GUI for windows.

Jan 31: Hyung-Hwan Chung offers QSE, an embeddable Awk Interpreter.

[More ...]

Bookmark and Share

categories: Databases,Spawk,Dec,2009,PanosP

Spawk for SUSE Linux

I've just installed the openSUSE Milestone 8 (11.2) in a virtual machine in my PC.

In about half an hour, I've also downloaded MySQL, gawk sources and SPAWK (SQL + AWK) sources, compiled and build the SPAWK libraries (/usr/lib/libspawk.so and /usr/lib/libspawk_r.so).

I've tested the module and worked just fine, so I've uploaded the binary tarball for this distro in SPAWK project (http://code.google.com/p/spawk/downloads/list).

Have a Happy New Year!
-- Panos Papadopoulos to tim


categories: Databases,Spawk,Jul,2009,PanosP

SPAWK moves to GoogleCode

Panos I. Papadopoulos reports that he has moved the SPAWK project (SQL and AWK) to Mercurial and spawk.googlecode.com.

He has also written extensive tutorial notes at the SPAWK wiki.


categories: Spawk,Databases,Jul,2009,PanosP

SQL Powered AWK

Website

http://sites.google.com/site/spawkinfo.

Author

Panos I. Papadopoulos (panos1962@gmail.com).

Description

SPAWK is an elegant collection of functions for accessing and updating MySQL databases from within GNU awk programs. The SPAWK module consists of a single awk extension library, namely libspawk.so, which may be loaded in awk programs using the standard extension awk function:

BEGIN {
   extension("libspawk.so", "dlload")
   ...

A Short Example

Here's a short example of using SPAWK (for more details, see http://sites.google.com/site/spawkinfo/Home/manual).

When calling spawk_select, SPAWK sends the query already given (maybe some spawk_query calls preceeded the spawk_select) to the current server (remind you that "server" in SPAWK's point of view is a connection to the actual MySQL server mysqld). After calling spawk_select, the server is ready to return the results to the awk process via spawk_data, spawk_first or spawk_last calls. Alternatively, at any time we can clear the results' set and release the server with a spawk_clear function call.

The main data receiver is spawk_data function. This function is usually called with one or two arguments. The first argument is an array to be used as a data transfer vehicle, while the second argument may be used optionally to hold the null valued columns. spawk_data returns the number of columns of each returned data row or zero if there are no more data to return (EOD). spawk_first function's arguments and return values are exactly the same as those of spawk_data arguments and returns values, but the rest of the data will be lost, that is get the next available data row and release the server. Similar is the spawk_last function, but the row returned is the last row of the results' set. By the way, the spawk_last function is less efficient than spawk_first; actually, there is no particular reason to call spawk_last at all! Let's see some examples:

BEGIN {
     extension("libspawk.so", "dlload")
     SPAWKINFO["database"] = "information_schema"
     spawk_select("SELECT TABLE_SCHEMA, TABLE_NAME FROM TABLES")
     while (spawk_data(data))
          print data[0]
     exit(0)
}

Things need to be explained:

  • extension is used to load the SPAWK module.
  • SPAWKINFO array is used to specify the default database (schema) to connect. Index "database" denotes default database.
  • spawk_select is used to execute the desired query.
  • spawk_data is used repeatedly to get the results, row by row. spawk_data returns 2 as there are results to be retuned and 0 on EOD.
blog comments powered by Disqus