一、将Oracle中的某张表导出到csv文件
import cx_Oracle
import pandas as pd
conn = cx_Oracle.connect('username', 'password', '127.0.0.1:1521/TESTDB')
sql = 'SELECT * FROM student'
df = pd.read_sql(sql, conn)
df.to_csv('student.csv')
print(df.head())
二、获得自身进程号并杀掉自身进程
import os
import time
# 获得当前进程号
pid = os.getpid()
print('pid:', pid)
for i in range(100):
print(i)
time.sleep(0.5)
if i == 11:
# 结束当前进程
os.system('kill -9 {}'.format(pid))