Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Using python defined functions in SQL statements?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Luke Whitehorn  
View profile  
 More options Jul 15 2012, 11:05 am
From: Luke Whitehorn <luke.whiteh...@gmail.com>
Date: Sun, 15 Jul 2012 08:05:11 -0700 (PDT)
Local: Sun, Jul 15 2012 11:05 am
Subject: Using python defined functions in SQL statements?

Hi all,
  I've just spent a few hours searching and came up with nothing so I
suspect that the answer to this question is a flat out 'no', but I'd like
to be able to confirm it.
So, is it possible to use a python defined function in an SQL query?
At the moment, I have to get data via a query, iterate though it and build
a python list of values calculated from my python function. I'd much rather
just have the function called during the query as it'd save me all these
steps.
So, is that possible?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chris Lambacher  
View profile  
 More options Jul 16 2012, 1:30 pm
From: Chris Lambacher <ch...@kateandchris.net>
Date: Mon, 16 Jul 2012 10:30:47 -0700 (PDT)
Local: Mon, Jul 16 2012 1:30 pm
Subject: Re: Using python defined functions in SQL statements?

Hi,

If you are using SQL Server, that is theoretically possible (though I have
never tried it) by using the .NET extensibility of SQL Server. Iron Python
is a .NET native version of Python that you could theoretically embed in
SQL Server and with a little bit of C# glue code have it run your Python
function on every row in the query.

Without details about what it is your function does and why you think it
would be better to run it in SQL Server, I question the usefulness of
trying to do this. Is it to limit the amount of data that gets sent
(because you create some kind of aggregate) or is this just a "hey neat I
can do that" kind of a question?

For what it is worth, PostgreSQL has the ability to run python functions
though embedding of a CPython interpreter, though I can't remember what it
is called.

-Chris


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
luke.whiteh...@gmail.com  
View profile  
 More options Jul 16 2012, 1:36 pm
From: luke.whiteh...@gmail.com
Date: Mon, 16 Jul 2012 10:36:35 -0700 (PDT)
Local: Mon, Jul 16 2012 1:36 pm
Subject: Re: Using python defined functions in SQL statements?

Thanks for the reply.
It's just a 'how neatly can I do that' kind of thing :) Furthermore
I'm using pyodbc to connect to an MS Access database, so I don't think
that it's actually possible in my situation. It's not too big of a
deal, but it's just a bit of a pain to do a secondary step of
processing that could easily be done in SQL if it had access to a
function (all the function would have done is to take a value, and
return something of the same type, nothing crazy).
I'm relatively new to this way of working with databases so I wasn't
sure if it was a common thing to let SQL do some of the processing for
you, or to just use SQL to get the information that you then process
in Python itself.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »