logo       

pl/pyton: exceptions.ImportError: No module named email.Parser: msg#00063

Subject: pl/pyton: exceptions.ImportError: No module named email.Parser
Hi,

I need to parse e-mail messages in pl/python functions. So, I write:

dbmail=# create or replace function get_header(varchar) returns varchar as $$
dbmail$# import email.Parser
dbmail$# parser = email.Parser.Parser()
dbmail$# message = parser.parse(args[0])
dbmail$# return message.get("From")
dbmail$# $$ language plpythonu;
CREATE FUNCTION
dbmail=#
dbmail=# select get_header(messageblk) from dbmail_messageblks;
ERROR:  plpython: function "get_header" failed
DETAIL:  exceptions.ImportError: No module named email.Parser

Simple pl/python functions works fine:

dbmail=# create or replace function test(varchar) returns varchar as $$
dbmail$# return args[0]
dbmail$# $$ language plpythonu;
CREATE FUNCTION
dbmail=#
dbmail=# select test('test');
 test
------
 test
(1 record)

Message parsing with standalone python works too:

$ cat mail.py
import sys
import email.Parser
parser = email.Parser.Parser()
message = parser.parse(sys.stdin)
print message.get("From")
$ python mail.py < mbox
test@xxxxxxxxxxxx

Why can't I use "import email.Parser" in pl/python function?

--
Thanks,
Eugene Prokopiev

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
      choose an index scan if your joining column's datatypes do not
      match



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
science.linguis...    culture.sf.lite...    video.mplayer.c...    yellowdog.gener...    ietf.rfc822/199...    emacs.help/2002...    redhat.release....    kernel.speakup/...    java.openejb.de...    debian.devel.gt...    xfree86.newbie/...    bug-tracking.ma...    pam/2003-05/msg...    games.devel.ope...    user-groups.lin...    music.pancham/2...    network.mq.deve...    web.html.genera...    arklinux.bugs/2...    linux.ecasound/...    qnx.openqnx.dev...    org.user-groups...    file-systems.sf...    trustix.contrib...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe