Python & Oracle Requirements Installation Oracle Instant Client

Slides:



Advertisements
Similar presentations
Why is that LOV in the screen not returning me desired value?
Advertisements

Overview of performance tuning strategies Oracle Performance Tuning Allan Young June 2008.
ORACLE TRANSACTIONS A transaction begins with the first executable SQL statement after a commit, rollback or connection made to the Oracle engine. All.
Acknowledgments Byron Bush, Scott S. Hilpert and Lee, JeongKyu
Data Access Worldwide May 16 – 18, 2007 Copyright 2007, Data Access Worldwide May 16 – 18, 2007 Copyright 2007, Data Access Worldwide Standardizing Application.
Murali Mani Persistent Stored Modules (Stored Procedures) : PSM.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 13 Introduction to SQL Programming Techniques.
1 - Oracle Server Architecture Overview
Basic JDBC Use Oracle JDBC Drivers must be in the CLASSPATH
Bruce Armstrong TeamSybase
OLE and ODBC: Taming the Technologies The Third Annual Perl Conference, 1999 Sunday, August 22, 1999Roth Consulting ODBC.
Getting Started with Oracle11g Abeer bin humaid. Create database user You should create at least one database user that you will use to create database.
Advanced Databases Advanced PL/SQL Programming: Procedure, Function and Package.
Bordoloi and Bock CURSORS. Bordoloi and Bock CURSOR MANIPULATION To process an SQL statement, ORACLE needs to create an area of memory known as the context.
Agenda Journalling More Embedded SQL. Journalling.
PDO, PHP Data Object Use a Database with PHP
Sayed Ahmed Computer Engineering, BUET, Bangladesh MSC, Computer Science, U of Manitoba, Canada
Chapter Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.
Basic Oracle Architecture
By Lecturer / Aisha Dawood 1.  You can control the number of dispatcher processes in the instance. Unlike the number of shared servers, the number of.
Python MySQL Database Access
JDBC (Java Database Connectivity) SNU OOPSLA Lab. October 2005.
Oracle SQL Query and Transactions By Shyam Gurram.
Oracle Locking Michael Messina Principal Database Analyst Indiana University.
1 Oracle Architectural Components. 1-2 Objectives Listing the structures involved in connecting a user to an Oracle server Listing the stages in processing.
Copyright  Oracle Corporation, All rights reserved. 1 Oracle Architectural Components.
Connecting to Oracle using Java November 4, 2009 David Goldschmidt, Ph.D. David Goldschmidt, Ph.D.
JDBC Java and Databases, including Postgress. JDBC l Developed by Industry leaders l Three main goals: –JDBC should be an SQL-level API –JDBC should capitalize.
Dr Gordon Russell, Napier University Unit Embedded SQL - V3.0 1 Embedded SQL Unit 5.1.
Lecture 8 Creating Stored Functions. Objectives  After completing this lesson, you should be able to do the following:  What is Function?  Types of.
Session 7: Getting PHP to Talk to MySQL. Objectives Connecting to the Database Building & Executing the SQL SELECT Query Fetching & Displaying the data.
JDBC. Preliminaries Database Database Collection of data Collection of data DBMS DBMS Database management system Database management system Stores and.
Improving Database Performance Derrick Rapley
JDBC – Java Database Concentricity
DATABASE TOOLS CS 260 Database Systems. Overview  Database accounts  Oracle SQL Developer  MySQL Workbench.
Database Technology Jing Shen.
1 CS 430 Database Theory Winter 2005 Lecture 14: Additional SQL Topics.
Li Tak Sing COMPS311F. Database programming JDBC (Java Database Connectivity) Java version of ODBC (Open Database Connectivity) ODBC provides a standard.
Using SQL in PL/SQL Oracle Database PL/SQL 10g Programming Chapter 4.
CHAPTER 10 PHP MySQL Database
12 Copyright © Oracle Corporation, All rights reserved. User-Managed Complete Recovery.
A Guide to SQL, Eighth Edition Chapter Six Updating Data.
Introduction to PL/SQL Francis Thottungal. The outline The basic PL/SQL code structure is : DECLARE -- optional, which declares and define variables,
Program with PL/SQL Lesson 3. Interacting with the Oracle Server.
Oracle Query VBA Tool (OQVT)
Introduction to Oracle  Oracle Database XE, APEX and Oracle SQL Developer.
MySQL-database kaivos.csc.fi. MySQL-database  MySQL database server linked to supercomputer  Enables users.
1 Chapter 5: Advanced PL/SQL Programming. 2 Anonymous PL/SQL Programs Write code in text editor, execute it in SQL*Plus Code can be stored as text in.
Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe.
Delete Data Database Administration Fundamentals LESSON 3.4.
COMP 430 Intro. to Database Systems Transactions, concurrency, & ACID.
Oracle Database Architectural Components
Introduction to pysqlite
CompSci 280 S Introduction to Software Development
CS3220 Web and Internet Programming Database Access with JDBC
SQL Environment.
Web Technologies IT230 Dr Mohamed Habib.
Chapter 1 Introduction.
SQL – Transactions in SQLite
Windows 94
DB2.
Chapter 1 Introduction.
Oracle Memory Internals
Create New User in Database. First Connect the System.
Oracle Architectural Components
Automate Database Deployment with Python
Chapter 1 Introduction.
CS3220 Web and Internet Programming Database Access with JDBC
CS3220 Web and Internet Programming Database Access with JDBC
Presentation transcript:

Python & Oracle Requirements Installation Oracle Instant Client cx_Oracle module http://cx-oracle.sourceforge.net/ Installation Windows: Win Installer Linux: RPM or cx_Oracle.so

Example: accessing database import cx_Oracle connection = cx_Oracle.connect('username/password@localhost') cursor = connection.cursor() bind_vars={'uid':25} sql='SELECT id,Firstname,Lastname FROM TB_NAME where id>:uid‘ cursor.execute( sql, bind_vars) rows = cursor.fetchall() for id,firstname,lastname in rows: print str(id)+' '+firstname+' '+lastname+"\n“ cursor.close() connection.close()

Example: connection pooling import cx_Oracle pool = cx_Oracle.SessionPool( USER, PASSWORD, TNS, 1, #min number of sessions controlled by pool 3, #max number of sessions controlled by pool 1, #additional sessions to be opened per acquire DB.Connection, #connection type True) #OCI_THREADED pool.timeout = 120 #idle session timeout #thread body first='Cristiano' lase='Ronaldo' connection = pool.acquire() cursor = connection.cursor() cursor.execute("insert into players values (:a,:b)", {'a':first,'b':last} ) connection.commit() cursor.close() #end of thread body pool.release(connection)

Connection API Functions Attributes begin() - explicitly begin a new transaction cancel() - cancel a long-running transaction close() - close connection commit() - commit any pending transactions to the database cursor() - returns new cursor objects ping() - tests if the connection is still active rollback() - rollback any pending transactions Attributes autocommit - read-write, autocommit mode is on or off current_schema - read-write, sets the current schema for the session password - read-write encoding - read-only, character set in use by the Oracle client stmtcachesize - read-write, specifies the size of the statement cache tnsentry - read-only, returns the TNS entry of the database username - read only version - read-only, version of the database

Cursor API Functions Attributes callfunc(name, returnType, parameters=[], keywordParameters = {}) callproc(name, parameters=[], keyewordParameters = {}) connection() - returns a reference to the connection object bindnames() - return list of bind variable names execute(statement[, parameters], **keywordParameters) executemany(statement, parameters) fetchall() fetchmany([numRows=cursor.arraysize]) fetchone() - fetching of next row next() - like fetchone() parse(statement) - does parsing only prepare(statement[, tag]) – does preparation of the statement close() Attributes arraysize -  read-write, number of rows to fetch bindvars - read-onle, bind variables used for the last execute rowcount - read-only, number of rows fatched