How to sql scripts in a file?

John Zhang <[email protected]> Thu, 23 Apr 2020 08:42:46 -0400
Newsgroups gmane.comp.gis.postgis,gmane.comp.db.postgresql.sql
Message-ID <CAKDSG9AULGW-rdC9_KArVm2D=GPmcUce+n0kAFSDKfWtqVGnmA@mail.gmail.com>
--===============7915190336263388150==
Content-Type: multipart/alternative; boundary="0000000000009b631d05a3f49662"

--0000000000009b631d05a3f49662
Content-Type: text/plain; charset="UTF-8"

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

--0000000000009b631d05a3f49662
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr">Hello all,<div><br></div><div>I have a ne=
ed to execute sql scripts in a file with comments in Python 2.7.=C2=A0</div=
><div>here is m code snippet:</div><div dir=3D"ltr"><br></div>sqlF =3D r&#3=
9;{}\{}&#39;.format(sFldr_sql,sSQLFile)<br>sql_file_contents =3D open(sqlF,=
&#39;r&#39;).read()<br><div>cur.execute(sql_file_contents)</div><div>=C2=A0=
</div><div>the file can be executed from pgAdmin successfully. However, the=
 code above runs quietly without any issues raised but NO results was worke=
d out.</div><div><br></div><div>In the sql file, there are scripts to DROP=
=20

FUNCTION=C2=A0 IF EXISTS and CREATE OR REPLACE FUNCTION.</div><div><br></di=
v><div>Your input to shed light on it would be much appreciated.</div><div>=
<br></div><div>Thank you</div><div><br></div></div>-- <br><div dir=3D"ltr" =
class=3D"gmail_signature"><span style=3D"font-family:arial,sans-serif;font-=
size:12.5px;border-collapse:collapse;color:rgb(136,136,136)"><div><span sty=
le=3D"color:rgb(102,102,102);font-family:Verdana,Arial,Tahoma;line-height:2=
0px;border-collapse:separate">Yours sincerely,</span></div><div><br></div><=
div><br></div><div>John Zhang</div><br><div><br></div></span></div></div>

--0000000000009b631d05a3f49662--

--===============7915190336263388150==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline

X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KcG9zdGdpcy11
c2VycyBtYWlsaW5nIGxpc3QKcG9zdGdpcy11c2Vyc0BsaXN0cy5vc2dlby5vcmcKaHR0cHM6Ly9s
aXN0cy5vc2dlby5vcmcvbWFpbG1hbi9saXN0aW5mby9wb3N0Z2lzLXVzZXJz

--===============7915190336263388150==--