Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

For example, say I wanted to have one column take the row id and run it through a Python script which returns some information related to that number (random example).

Would I need to manually populate the database with this information, or is there some mechanism to do this from within the database?

share|improve this question
    
Did you consider PL/Python? –  kupson Feb 11 '12 at 11:53
add comment

1 Answer

PL/Python seems like the obvious choice. Here's a little quick tutorial to get you started. This is useful for situations where you need the database to automatically perform some operation (e.g. trigger), or from a stored procedure and your language of choice is python.

However, if it's just a one-off operation to go over all data and update something, it's probably better to write this outside the database in a script and just run it against the database. Generally speaking, maintaining your code outside the database itself is better. You can more easily version-control it, run tests against it and update it as necessary. That of course depends on many factors so it's more a question of preference than something definitive. PL/Python wouldn't exist if it didn't have a legitimate use-case (and obviously it does).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.