#!/usr/bin/env python
# coding=utf-8

import cx_Oracle
import matplotlib.pyplot as plt
import numpy as np
from docx import Document
from docx.shared import Inches


db = cx_Oracle.connect('system/916488476@192.168.100.110/dev')

cursor = db.cursor()
sqltxt1 = 'select user_percent,system_percent,io_wait_percent from cpu_useage'
x1 = cursor.execute(sqltxt1)
row1=x1.fetchall()

sqltxt2 = 'select load1 from cpu_useage'
x2 = cursor.execute((sqltxt2))
row2=x2.fetchall()


plt.plot(row1)
plt.grid(axis='y')
plt.savefig("D:test\examples.jpg")
plt.show()

plt.plot(row2)
plt.grid(axis='y')
plt.savefig("D:test\examples1.jpg")
plt.show()

cursor.close()


db.close()


document = Document()

document.add_heading(u'2018-03-29 数据库巡检记录', level=0)
document.add_heading('The role of dolphins', level=1)

document.add_paragraph(u'CPU趋势图')


document.add_picture('D:test\examples.jpg', width=Inches(6))

document.add_paragraph(u'CPU趋势图')
document.add_picture('D:test\examples.jpg', width=Inches(6))

document.save('D:test\demo.docx')





