Job Search

Monday, August 14, 2017

Setting up Oracle, Python and Eclipse


Installing Python 3 and Eclipse for Windows

Note:  Keep in mind that PyDev 5.x requires Eclipse 4.6 onwards (for Eclipse 3.8 use PyDev 4.x).
The highest version of 4.x listed is 4.5.5; we can copy the link http://www.pydev.org/update_sites/4.5.5 and paste into eclipse's Install New Software

Steps to configure Python with Eclipse:
Step 1: Install java
Step 2: Install Python 3
Step 3: Install or Extract eclipse

Ø Open Eclipse -> Help -> Install New Software... -> Add
·  Name: PyDev
·  Location: http://pydev.org/updates (or specific path for your eclipse version)

Ø Click OK
Ø Select "PyDev for Eclipse" and remain all default
Ø Click Next -> review the items to be installed -> Next
Ø Check "I accept the terms of the license agreement -> Finish
Ø Accept the certificates -> Click OK
Ø Restart Eclipse
Ø Open Eclipse -> Windows -> Preferences -> expand "PyDev" -> Interpreter - Python --> click on New and select the python executable (python.exe) from the python installed location -> Click OK -> Click OK
Ø General -> Editors -> Text Editors -> check Show Line Numbers -> OK (and it's going to go in and configure Python.)
Ø Under Perspectives -> Other -> select the "PyDev" perspective, because that's what we're going to be using.
Ø Right click on Java -> close, if java development is not required.

Now we're ready to create and configure our new python project with eclipse.

Python Interpreter Configuration
Ø  Select Window -> Preferences -> PyDev -> Interpreters -> Python Interpreter -> New (or Auto-Config).
Ø  Select location of python.exe for which cx_Oracle has been configured (32 Bit or 64 Bit), check oracle database server or client version using
Ø  Run-> cmd -> tnsping
Ø  Apply - > OK

Python cx_Oracle Configuration
Ø  Select Window -> Preferences -> PyDev -> Interpreters -> Python Interpreter -> Forced Builtins
Ø  New -> cx_Oracle -> OK


Python Oracle Project

Ø  Select File -> New-> PyDev Project
Ø  Project Name -> MyDemo
Ø  Project Type -> Python
Ø  Grammar Version -> 3-3.5
Ø  Interpreter -> Python
Ø  Finish

Ø  Right Click on Project Name (MyDemo)
Ø  New-> PyDev Module
Ø  Name -> DBTest

Paste below code in DBTest.py file

# Code start
import cx_Oracle
class MyClass(object):
    '''
    classdocs
    '''


    def __init__(self):
        con = cx_Oracle.connect('hr/hr@orcl')
        # do some stuff here
        #ver = con.version.split(".")
        #print(ver)
        #print(con.version)
        cur = con.cursor()
  cur.execute('select e.employee_id,e.first_name,e.last_name from  EMPLOYEES e where rownum<2 order by 2')
        for result in cur:
            #print(result)
            print(result[0],",",result[1]," ",result[2])
        cur.close()   
        con.close()
        '''
        Constructor
        '''

MyClass()      
# Code end

Execute Python Module

Run -> Run As -> 1 Python Run

Output
Console

100 , First_Name Last_Name


I hope you all have enjoyed reading this article. Comments are welcome....


Related Posts:
- Connect Python 3.6 with Oracle 12c on Windows 7 x64
- Oracle subprograms and Python Programming

Tuesday, August 8, 2017

Connect Python 3.6 with Oracle 12c on Windows 7 x64

To use Python with Oracle below components must all be in place and be of the same version (Python 3.6 suggested) and same architecture (64-bit suggested).

Windows 7 x64
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
Python 3.6 x64 (python-3.6.0-amd64.exe)
cx_Oracle (cx_Oracle-5.3-12c.win-amd64-py3.6-2.exe)

Instance running in 64-bit. To do this, we must have installed:
  • Part 1: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
Or Oracle 12c 64-bit Windows Instant Client 
  • Part 2: Python 3.6 x64 (python-3.6.0-amd64.exe) (64bit)
  • Part 3: cx_Oracle (cx_Oracle-5.3-12c.win-amd64-py3.6-2.exe) (64bit)

Part 1: Install Oracle Database 12c
Download and install Oracle Database 12c from below location


or
Download and install Oracle Database 12c Instant Client from below location


Part 2: Install Python 3.6 x64
Download and install Python 3.6 x64 (Windows x86-64 executable installer) from below location


Part 3: Install Python interface to Oracle (cx_Oracle-5.3-12c.win-amd64-py3.6-2.exe)
Download and install Python interface to Oracle (cx_Oracle-5.3-12c.win-amd64-py3.6-2.exe) from below location

Does it Work?
Now it is time to test the connection. We can execute the following code to test the connectivity.

Steps
Step 1: Create db_conn_test.py file

import cx_Oracle
con = cx_Oracle.connect('hr/hr@orcl')
# do some stuff here
#ver = con.version.split(".")
#print(ver)
print(con.version)
con.close()

Step 2:  open IDLE (Python 3.6 64-bit)
File -> Open -> select db_conn_test.py file

Step 3:
Run -> Run Module

Output:
Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>>
============ RESTART: D:\Study\Python\Python_code\db_conn_test.py ============
12.1.0.2.0
>>> 

It will display current oracle database version.


Example: Display data from HR schema tables

import cx_Oracle
con = cx_Oracle.connect('hr/hr@orcl')
# do some stuff here
ver = con.version.split(".")
print(ver)
cur = con.cursor()
cur.execute('select * from EMPLOYEES e where e.employee_id < 150 order by 2')
for result in cur:
    print(result)
cur.close()          
con.close()



I hope you all have enjoyed reading this article. Comments are welcome....


Related Posts:
- Oracle subprograms and Python Programming

Wednesday, July 19, 2017

Comparison Netezza vs. Oracle vs. Teradata by DB-Engines



Name
Netezza (Also called PureData System for Analytics by IBM)
Oracle  
Teradata  
Description
Data warehouse and analytic appliance
Widely used RDBMS
DBMS mainly used for data warehousing
Database model
DB-Engines Ranking (measures the popularity of database management systems)
Score     19.86
Rank      #29   Overall
  #17 Relational DBMS
Score  1374.88
Rank   #1 Overall
                 #1 Relational DBMS
Score 78.37
Rank  #12 Overall
      #8 Relational DBMS
Website
Technical documentation
Developer
IBM
Oracle
Teradata
Initial release
2000
1980
1979
Current release
12 Release 2 (12.2.0.1), March 2017
License (Commercial or Open Source)
commercial
commercial (restricted free version is available)
commercial
Cloud-based (Only available as a cloud service)
no
no
no
Implementation language
C and C++
Server operating systems
Linux (included in appliance)
AIX
HP-UX
Linux
OS X
Solaris
Windows
z/OS
Linux
Data scheme
yes
yes
yes
Typing (predefined data types such as float or date)
yes
yes
yes
XML support (Some form of processing data in XML format, e.g. support for XML data structures, and/or support for XPath, XQuery or XSLT)
yes
Secondary indexes
yes
yes
yes (special 'join index' to physically pre-join tables)
SQL (Support of (almost entire) SQL standard (DML, DDL and DCL statements))
yes
yes
yes
APIs and other access methods
JDBC
ODBC
OLE DB
ODP.NET
Oracle Call Interface (OCI)
JDBC
ODBC
.NET Client API
JDBC
JMS Adapter
ODBC
OLE DB
Supported programming languages
C
C++
Fortran
Java
Lua
Perl
Python
R
C
C#
C++
Clojure
Cobol
Delphi
Eiffel
Erlang
Fortran
Groovy
Haskell
Java
JavaScript
Lisp
Objective C
OCaml
Perl
PHP
Python
R
Ruby
Scala
Tcl
Visual Basic
C
Cobol
Java (JDBC-ODBC)
PL/1
Python
R
Server-side scripts (Stored procedures)
yes
PL/SQL (also stored procedures in Java possible)
yes
Triggers
no
yes
yes
Partitioning methods (Methods for storing different data on different nodes)
Sharding
horizontal partitioning (with the optional Oracle Partitioning)
Sharding (shared nothing architecture)
Replication methods (Methods for redundantly storing data on multiple nodes)
Master-slave replication
Master-master replication
Master-slave replication
Master-master replication
MapReduce (Offers an API for user-defined Map/Reduce methods)
yes
no (can be realized in PL/SQL)
no
Consistency concepts (Methods to ensure consistency in a distributed system)
Immediate Consistency
Foreign keys (Referential integrity)
no
yes
yes
Transaction concepts (Support to ensure data integrity after non-atomic manipulations of data)
ACID
ACID (isolation level can be parameterized)
ACID
Concurrency (Support for concurrent manipulation of data)
yes
yes
yes
Durability (Support for making data persistent)
yes
yes
yes
In-memory capabilities (Is there an option to define some or all structures to be held in-memory only)
yes (Version 12c introduced the new option 'Oracle Database In-Memory')
yes
User concepts (
Access control)
Users with fine-grained authorization concept
fine grained access rights according to SQL-standard
fine grained access rights according to SQL-standard


I hope you all have enjoyed reading this article. Comments are welcome....