Skip to content

Instantly share code, notes, and snippets.

@riffm
Created September 16, 2009 09:44
Show Gist options
  • Save riffm/187966 to your computer and use it in GitHub Desktop.
Save riffm/187966 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
import sys
from psycopg2 import connect
from DBSingleStyle import Param, to_format
if __name__=='__main__':
query = ('SELECT table_name, column_name, data_type \
FROM information_schema.columns WHERE table_name=', Param(sys.argv[1]))
conn = connect("dbname='template1' user='postgres' host='localhost'")
cur = conn.cursor()
cur.execute(*to_format(query))
for row in cur.fetchall():
print row
conn.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment