Forum Stats

  • 3,735,108 Users
  • 2,247,109 Discussions
  • 7,857,685 Comments

Discussions

Pythonic PL/SQL programs?

103122
103122 Member Posts: 16
edited Jul 8, 2010 9:46AM in Python
I'm itching to begin creating a bunch of PL/SQL packages that will emulate certain handy Python features, but before I sink too much time into it... does anybody know of something like this already written?

The needs I'm feeling right now are for string manipulation (I'm sure many more will follow):

Python3-style string substitution: 'The {0} brown fox jumped over the {1} dog'.format('quick','brown')
.join()
.split()
.splitlines()
... and so forth

I think this package would not just implement the ones that don't exist in SQL/PLSQL, it will provide Pythonically familiar names and interfaces to the ones that do exist.

Answers

  • Christopher Jones-Oracle
    Christopher Jones-Oracle Member Posts: 1,630 Employee
    Have you seen Raimond's Ruby gem http://github.com/rsim/ruby-plsql ?
  • 103122
    103122 Member Posts: 16
    I don't think that will do what I need; I need PL/SQL programs to be able to use Python (or Ruby) -type powers, not the other way around. cx_Oracle also allows calling PL/SQL from Python programs, but that won't help me, either, because this is for triggers, procedures, etc. that are invoked inside the database. Calling into the database from outside has always been easy.
  • 390020
    390020 Member Posts: 446
    Hey Catherine, sound like fun and no, I don't know any package that's already provides such functionality. Are you planning to use OO PL/SQL?
  • 410266
    410266 Member Posts: 56
    edited Jul 8, 2010 12:01AM
    Hi Catherine, this is by you right ?
    http://www.oracle.com/technology/pub/articles/devlin-python-oracle.html

    I thought your name looks familiar. I have that article tagged {python, oracle} heheh.

    I'm only aware of and have been consistently using (since 2001) one single ready-made PL/SQL library that provide common functionalities - codes MOST places re-invent over and over and over....it is PLVision, originally by Steve Feuerstein.

    Not to sound negative but in my experience, it's amazing majority of the long-time PL/SQL developers I have come across have never heard of this library.

    Now..if only Oracle would embed Python VM in the server, that would be oh sooo sweet.
  • 103122
    103122 Member Posts: 16
    Yes, that's my article! There are some things I'd change in it if I were writing it now...

    I hadn't heard of PLVision either - thanks! You're right, it's just tragic how the ethos of code sharing and reuse hasn't caught on among PL/SQL community. I guess it's partially because everything you might use is scattered all over the place. Maybe that's the innovation PL/SQL really needs to borrow most: a PL/SQL equivalent to the Cheese Shop or CPAN.

    By the way, I ended up getting a (very small) start on Pythonic PL/SQL: http://catherinedevlin.blogspot.com/2010/04/pythonic-plsql.html
This discussion has been closed.