How to sql scripts in a file?

From: John Zhang <johnzhang06(at)gmail(dot)com>
To: postgis-users(at)lists(dot)osgeo(dot)org, pgsql-sql(at)postgresql(dot)org
Subject: How to sql scripts in a file?
Date: 2020-04-23 12:42:46
Message-ID: CAKDSG9AULGW-rdC9_KArVm2D=GPmcUce+n0kAFSDKfWtqVGnmA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello all,

I have a need to execute sql scripts in a file with comments in Python 2.7.
here is m code snippet:

sqlF = r'{}\{}'.format(sFldr_sql,sSQLFile)
sql_file_contents = open(sqlF,'r').read()
cur.execute(sql_file_contents)

the file can be executed from pgAdmin successfully. However, the code above
runs quietly without any issues raised but NO results was worked out.

In the sql file, there are scripts to DROP FUNCTION IF EXISTS and CREATE
OR REPLACE FUNCTION.

Your input to shed light on it would be much appreciated.

Thank you

--
Yours sincerely,

John Zhang

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Sándor Daku 2020-04-23 13:08:19 Fwd: How to sql scripts in a file?
Previous Message Ashutosh Sharma 2020-04-22 16:31:08 Re: FK constraint question