Presentation is loading. Please wait.

Presentation is loading. Please wait.

Python for Oracle Geeks or, “Just a wafer-thin slice of Python” or, “Python as a Second Language (PSL)” Catherine Devlin IntelliTech Systems.

Similar presentations


Presentation on theme: "Python for Oracle Geeks or, “Just a wafer-thin slice of Python” or, “Python as a Second Language (PSL)” Catherine Devlin IntelliTech Systems."— Presentation transcript:

1 Python for Oracle Geeks or, “Just a wafer-thin slice of Python” or, “Python as a Second Language (PSL)” Catherine Devlin IntelliTech Systems

2 Outline ● Brainwashing ● Getting started ● Working with files ● Querying Oracle ● Building Web application

3 Me S. B. (sic) in Chemical Engineering Oracle DBA since1999 Pythonista since 2003 catherine.devlin@gmail.com http://catherinedevlin.blogspot.com/ IntelliTech Systems Fairborn, OH http://www.itsysteminc.com/

4 Tasks of a Database Administrator Task 1: Evaluate the Database Server Hardware Task 2: Install the Oracle Database Software Task 3: Plan the Database Task 4: Create and Open the Database Task 5: Back Up the Database Task 6: Enroll System Users Task 7: Implement the Database Design Task 8: Back Up the Fully Functional Database Task 9: Tune Database Performance Task 10: Download and Install Patches Task 11: Roll Out to Additional Hosts From Oracle® Database Administrator's Guide 10g Release 2 (10.2): “I work in the database.” Is that really all you do?

5 ● Data files on filesystem ● Batch files and executables ● System resources (memory, CPU) ● Internet ● Object-oriented programming ● Complex text parsing Sometimes SQL and PL/SQL aren't enough

6 ● Easy to learn and use ● Easy to read and maintain ● Powerful and versatile ● Free of cost! Dear Santa, I have been a very good DBA. For Christmas, I want a language that is... Consider a dynamic language (Perl, PHP, Ruby...)

7

8 Easy to learn and use Easy to read and maintain Very readable - “executable pseudocode” Unit testing Powerful and versatile Exception handling, XML Web publishing, Web browsing, Web services, GUI development... Free of cost!

9

10 Let's write something! Compare init.ora file to parameters in database db_block_size=8192 -OK- compatible=10.2.0.10 (live) 9.2.0.1 (file) cursor_sharing=EXACT -OK- Web application

11 www.python. org DEMO

12

13

14 Pitfalls for the Oracle-minded 1. Everything is case-sensitive

15

16 object-orientation

17

18 Pitfalls for the Oracle-minded 1. Everything is case-sensitive 2. When calling a function, () is not optional

19

20

21

22

23

24

25

26

27 fileParams = { 'log_archive_start': True, 'db_block_size': 8192 } What we want is a table In Python, it's called a 'dictionary' and indicated by {}

28

29

30 STOP IT! Write a script already!

31

32 Pitfalls for the Oracle-minded 1. Everything is case-sensitive 2. When calling a function, () is not optional 3. No knee-jerk indenting!

33

34

35 Are you confused about where the “for” block begins and ends? Even though there is no END LOOP? Are you confused about where each command ends? Even though there are no semicolons? Python reads your code the same way your eye does!

36

37

38 Python core You have access without doing anything Standard library You must 'import' into a script or session External modules You must go get and install the code then import

39

40

41

42

43

44

45

46 1. Choose a web application platform Albatross, Aquarium, CherryPy, Cymbeline, Django, Draco, Impostor, JOTWeb, Karrigell, mod_python, Nevow, Paste, Python Servlet Engine, PyWork, QLime, Quixote, SkunkWeb, Snakelets, SnakeSkin, Subway, Twisted, TurboGears, WareWeb, WebWare, Zope

47 1. Choose a web application platform CherryPy – my favorite TurboGears – compare to Ruby on Rails (no Oracle support, yet) Zope – most popular; Web administration Plone – content management 2. Download and install 3. Read the CherryPy tutorial

48 Pitfalls for the Oracle-minded 1. Everything is case-sensitive 2. When calling a function, () is not optional 3. No knee-jerk indenting! 4. CherryPy tutorial is one version obsolete

49

50

51

52

53

54 Bind variables in cx_Oracle Use a :colon in the SQL string, then send a dictionary as second argument cursor.execute( “””SELECT hiredate FROM emp WHERE ename = :empName”””, {'empName':'SCOTT'})

55 What's next? www.python.org Documentation > Tutorial Object-orientation Convenience wrapper: sqlWrap.py Object-relational mapping (a la Oracle TopLink) Exception handling, unit testing,...

56 References www.python.org > Topic Guides > Databases http://www.computronix.com/utilities.sh tml http://www.amk.ca/python/writing/DB- API.html http://www.ioug.org/Python.pdf http://catherinedevlin.blogspot.com


Download ppt "Python for Oracle Geeks or, “Just a wafer-thin slice of Python” or, “Python as a Second Language (PSL)” Catherine Devlin IntelliTech Systems."

Similar presentations


Ads by Google