executing a sql script

From: johnf <jfabiani(at)yolo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: executing a sql script
Date: 2009-01-17 06:09:06
Message-ID: 200901162209.06592.jfabiani@yolo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I'm using python and can execute standard "select,update,delete,functions".
What I'd like to do is execute a sql script (a text file). But I don't know
how?
Some thing like:
import psycopg2
import psycopg2.extensions
conn = psycopg2.connect("host=%s dbname=%s user =%s password
=%s " %(self.pgSqlHostID.Value,self.pgSqlDatabaseID.Value,self.pgSqlUserID.Value,self.msSqlPasswordID.Value))

conn.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT)
tempCursor= conn.cursor()
try:
tempCursor.execute("run script %s " % FileNameScript)
tempCursor.execute('commit')
--
John Fabiani

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Faheem Mitha 2009-01-17 07:09:38 array_agg for 8.3
Previous Message Vincent Predoehl 2009-01-17 04:32:56 accessing user table structures from SQL