Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
"""Simple script to read stdin postgresql csv logs and output the SQL statements
To use, do something like this:
tail -f /path/to/your/postgres.log | python -u
import csv
import sys
from functools import partial
import sqlparse
formatter = partial(sqlparse.format, reindent=True)
except ImportError:
formatter = lambda l: l
reader = csv.reader(iter(sys.stdin.readline, ''))
for row in reader:
print formatter(row[13])
except IndexError:
print row
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.