Skip to content

Instantly share code, notes, and snippets.

@nodamu
Created July 11, 2019 18:18
Show Gist options
  • Save nodamu/5fe7483c424ebd8a2e8789a1a349f91f to your computer and use it in GitHub Desktop.
Save nodamu/5fe7483c424ebd8a2e8789a1a349f91f to your computer and use it in GitHub Desktop.

Revisions

  1. nodamu created this gist Jul 11, 2019.
    42 changes: 42 additions & 0 deletions cron.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,42 @@
    #-----ORACLE SECTION---------#
    import cx_Oracle
    from pptx import Presentation

    try:
    dsn_tns = cx_Oracle.makedsn('Host Name', 'Port Number', service_name='Service Name')
    conn = cx_Oracle.connect(user=r'User Name', password='Personal Password', dsn=dsn_tns)

    # Now execute the sqlquery
    cursor = conn.cursor()
    cursor.execute("insert into student values(19585, Niranjan Shukla, 72000")
    for row in cursor:
    print (row[0], '-', row[1])

    # commit that insert the provided data
    # con.commit()

    prs = Presentation()
    title_slide_layout = prs.slide_layouts[0]
    slide = prs.slides.add_slide(title_slide_layout)
    title = slide.shapes.title
    subtitle = slide.placeholders[1]

    title.text = "Hello, World!"
    subtitle.text = "python-pptx was here!"

    prs.save('test.pptx')

    cursor.close()

    except cx_Oracle.DatabaseError as e:
    print("There is a problem with Oracle", e)

    # by writing finally if any error occurs
    # then also we can close the all database operation
    finally:
    if cursor:
    cursor.close()
    if conn:
    conn.close()