2018年12月25日火曜日

cgiでpython3を動かす。

# vi /etc/httpd/conf/httpd.conf
<Directory "/var/www/cgi-bin">
    AllowOverride None
    Options ExecCGI
    Require all granted
    AddHandler cgi-script .py .pyc
</Directory>

# vi /etc/sysconfig/httpd
LD_LIBRARY_PATH=/opt/libs/oracle:$LD_LIBRARY_PATH

# systemctl restart httpd

#vi /var/www/cgi-bin/oracle.py
#!/usr/bin/env python36import cx_Oracle
import osimport sys
import io
os.environ["NLS_LANG"] = "JAPANESE_JAPAN.JA16SJISTILDE"
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
print("Content-Type: text/plain;charset=utf-8")
print()

HOST = '192.168.xx.xxx'
PORT = '1521'
SID = 'xxxxxxxx'

tns = cx_Oracle.makedsn(HOST, PORT, SID)
conn = cx_Oracle.connect("xxxxxxx", "xxxxxxx", tns)

print( conn.version)
cur = conn.cursor()
cur.execute("""select column_name,data_type,data_length from all_tab_columns where table_name='CCMxxx'""")
rows = cur.fetchall()

for r in rows:
   print("%s %s %s" % (r[0],r[1],r[2]))

cur.execute("""select * from CCMxxx""")
rows = cur.fetchall()
for r in rows:
   print("%s %s %s %s" % (r[0],r[1],r[2],r[3]))

0 件のコメント:

コメントを投稿

zabbix7 amazon linux2023 インストール postgres15

【postgres】 dnf -y install postgresql15-server postgresql15-server-devel postgresql-setup initdb passwd postgres vi `find / -name pg_hba.con...