Thread: Info

Info

From
"rino.79"
Date:
Hi, I'm Rino.
My question is:
How I can connect postgres database whit tcl/tk interface?
Thanks !

Re: Info

From
Jan Wieck
Date:
rino.79 wrote:
> Hi, I'm Rino.
> My question is:
> How I can connect postgres database whit tcl/tk interface?
> Thanks !

I use to have a subdirectory ./pgtcl in the Tcl package area, containing 
a symlink to the actual libpgtcl.so file in $PGLIB. In that directory I 
run pkg_mkIndex and then I can simply put
    package require Pgtcl

into the scripts to load the interface.


Jan

-- 
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#================================================== JanWieck@Yahoo.com #



Re: Info

From
JL
Date:
On Fri June 13 2003 14:23, rino.79 wrote:
> Hi, I'm Rino.
> My question is:
> How I can connect postgres database whit tcl/tk interface?

creates a new *.tcl file
__________________________
#!/usr/bin/tclsh
# Test of access to a database after install
# Table: customers
#     One Field used in test: lname
# 
# GRANT ALL customers TO user_whom_ever ;
#
# libarary for postgresQL 7.3.2
#         /usr/lib/libpgtcl.so -> /usr/lib/pgtcl1.4/libpgtcl1.4.so

load /usr/lib/libpgtcl.so

set pgsetup "user=user_whom_ever dbname=mydatabase psic password='mypassword_if_any'"

#  above used in the following way...
#   pg_connect -conninfo "user=user_whom_ever dbname=mydatabase psic password='mypassword_if_any'"

set pgconn [pg_connect -conninfo $pgsetup]

puts "Connection string  $pgsetup"

puts "__ Uppercase first character of customers last name ___\n"

pg_select $pgconn "Select DISTINCT substr(upper(lname),1,1) AS cid From customers LIMIT 18" arr {               puts
[format"%s" $arr(cid) ]
 
}
pg_select $pgconn "SELECT count(*) AS cnt FROM customers" arr {       puts [format "First 18 DISTINCT 1st characters,
froma total of: %s  customers" $arr(cnt) ]
 
}
pg_disconnect $pgconn


Note: below, you may find a tar package with
more code and database for a in works project 
for Linux

-- 
John Turner
http://Members.Ntelos.Net/~JLT

"Just because you do not know the answer,
does not mean that someone else does"
Sephen J. Gould {RIP}


PL/Python import _sre module error

From
Glenn R Williams
Date:
Hi All,

Does anyone else have a problem with importing the re package
I am using:

Redhat 9.0
PostgreSQL 7.3.3
Python 2.2.2.26

When I create a function:

import re
o = args[0]
b = re.match(r"^t.*",o)
if b:  return "fits the bill"
return "failed the test"

PostgreSQL fails, and returns the error message:

exceptions.ImportError: No module named _sre

If I go into python, this is not a problem, so I suppose it is somehow
due to the restricted execution environment and/or PostgreSQL. But
that's as far as I get.

Any suggestions on how to pinpoint the problem? Surely someone else is
using re (sre), since the other modules (pcre, pre) don't handle
unicode.

TIA

Glenn

Glenn R Williams
Software for the International Community
----------------------------------------------------------------------
Mathematical theories are the part of science you could continue to do
if you woke up tomorrow and discovered the universe was gone.

Re: PL/Python import _sre module error

From
Gerhard Häring
Date:
Glenn R Williams wrote:
> Hi All,
> 
> Does anyone else have a problem with importing the re package 
> I am using:
> 
> Redhat 9.0
> PostgreSQL 7.3.3
> Python 2.2.2.26
> 
> When I create a function:
> 
> import re
> o = args[0]
> b = re.match(r"^t.*",o)
> if b:
>    return "fits the bill"
> return "failed the test"
> 
> PostgreSQL fails, and returns the error message:
> 
> exceptions.ImportError: No module named _sre
> 
> If I go into python, this is not a problem, so I suppose it is somehow
> due to the restricted execution environment and/or PostgreSQL. But
> that's as far as I get.

Correct. re is not enabled, because you can create arbitrary cpu (and 
perhaps also memory) utilization with it. Thus it's unsafe.

> Any suggestions on how to pinpoint the problem? [...]

Fork pl/python and create an unsafe version without any restrictions? 
That's what I once did just for fun. I think that'll be necessary 
anyway, because with Python >= 2.2.3, rexec and friends are disabled anyway.

-- Gerhard


Re: PL/Python import _sre module error

From
Glenn R Williams
Date:
Thanks, Gerhard.

Now that rexec and friends are disabled in Python > 2.2.3, what is the
future of PL/Python? Will it wither away? I don't know how many other
modules are impacted by the same problem, but will pursue the matter on
the Python list. Thanks for your help, though!

Best Regards,
Glenn

On Mon, 2003-06-16 at 16:39, Gerhard Häring wrote:
> Glenn R Williams wrote:
> > Hi All,
> >
> > Does anyone else have a problem with importing the re package
> > I am using:
> >
> > Redhat 9.0
> > PostgreSQL 7.3.3
> > Python 2.2.2.26
> >
> > When I create a function:
> >
> > import re
> > o = args[0]
> > b = re.match(r"^t.*",o)
> > if b:
> >    return "fits the bill"
> > return "failed the test"
> >
> > PostgreSQL fails, and returns the error message:
> >
> > exceptions.ImportError: No module named _sre
> >
> > If I go into python, this is not a problem, so I suppose it is somehow
> > due to the restricted execution environment and/or PostgreSQL. But
> > that's as far as I get.
>
> Correct. re is not enabled, because you can create arbitrary cpu (and
> perhaps also memory) utilization with it. Thus it's unsafe.
>
> > Any suggestions on how to pinpoint the problem? [...]
>
> Fork pl/python and create an unsafe version without any restrictions?
> That's what I once did just for fun. I think that'll be necessary
> anyway, because with Python >= 2.2.3, rexec and friends are disabled anyway.
>
> -- Gerhard
>
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings
--
Glenn R Williams
Software for the International Community
----------------------------------------------------------------------
Mathematical theories are the part of science you could continue to do
if you woke up tomorrow and discovered the universe was gone.

Re: PL/Python import _sre module error

From
Gerhard Häring
Date:
Glenn R Williams wrote:
> Thanks, Gerhard.
> 
> Now that rexec and friends are disabled in Python > 2.2.3, what is the
> future of PL/Python? Will it wither away? [...]

I'd like to have PL/Python as an 'unsafe' language. That's what I wanted 
it in the first place. Because I usually have full control over the 
servers I run PostgreSQL on. So a restricted environment would only 
restrict myself, which I don't like ;-)

-- Gerhard


Re: PL/Python import _sre module error

From
Tom Lane
Date:
Gerhard Häring <lists@ghaering.de> writes:
> Glenn R Williams wrote:
>> Now that rexec and friends are disabled in Python > 2.2.3, what is the
>> future of PL/Python? Will it wither away? [...]

> I'd like to have PL/Python as an 'unsafe' language.

Send in a patch to make it so.  We have to do something with it, given
the loss of rexec, and none of the core developers have time for it.
        regards, tom lane