Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
9487ad84
Commit
9487ad84
authored
May 19, 1999
by
Marc G. Fournier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bring python up to date ... From: D'Arcy J.M. Cain <darcy@druid.net>
parent
77ebed09
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
489 additions
and
243 deletions
+489
-243
src/interfaces/python/Announce
src/interfaces/python/Announce
+16
-2
src/interfaces/python/ChangeLog
src/interfaces/python/ChangeLog
+11
-0
src/interfaces/python/README
src/interfaces/python/README
+22
-25
src/interfaces/python/pg.py
src/interfaces/python/pg.py
+21
-7
src/interfaces/python/pgmodule.c
src/interfaces/python/pgmodule.c
+419
-209
No files found.
src/interfaces/python/Announce
View file @
9487ad84
Announce
:
Release
of
PyGreSQL
version
2.
3
Announce
:
Release
of
PyGreSQL
version
2.
4
===============================================
===============================================
PyGreSQL
v2
.
3
has
been
released
.
PyGreSQL
v2
.
4
has
been
released
.
It
is
available
at
:
ftp
://
ftp
.
druid
.
net
/
pub
/
distrib
/
PyGreSQL
.
tgz
.
If
It
is
available
at
:
ftp
://
ftp
.
druid
.
net
/
pub
/
distrib
/
PyGreSQL
.
tgz
.
If
you
are
on
NetBSD
,
look
in
the
packages
directory
under
databases
.
If
you
are
on
NetBSD
,
look
in
the
packages
directory
under
databases
.
If
it
isn
't there yet, it should be there shortly. You can also pick up the
it
isn
't there yet, it should be there shortly. You can also pick up the
...
@@ -31,6 +31,9 @@ PostgreSQL features from a Python script.
...
@@ -31,6 +31,9 @@ PostgreSQL features from a Python script.
I wanted to have DB-SIG API support in the next release but there are
I wanted to have DB-SIG API support in the next release but there are
enough fixes and improvements to make one more release before starting
enough fixes and improvements to make one more release before starting
on that. The next version will be 3.0 and have the DB-SIG API support.
on that. The next version will be 3.0 and have the DB-SIG API support.
Note that I said this for 2.4 but some required changes from others have
been slow in coming (I'
m
not
complaining
,
people
do
have
lives
)
and
there
were
enough
fixes
that
I
didn
't want to keep them from a release.
PyGreSQL 2.3 was developed and tested on a NetBSD 1.3_BETA system. It
PyGreSQL 2.3 was developed and tested on a NetBSD 1.3_BETA system. It
is based on the PyGres95 code written by Pascal Andre,
is based on the PyGres95 code written by Pascal Andre,
...
@@ -39,6 +42,17 @@ code for Python 1.5 and PostgreSQL 6.2.1. While I was at it I upgraded
...
@@ -39,6 +42,17 @@ code for Python 1.5 and PostgreSQL 6.2.1. While I was at it I upgraded
the code to use full ANSI style prototypes and changed the order of
the code to use full ANSI style prototypes and changed the order of
arguments to connect. Later versions are fixes and enhancements to that.
arguments to connect. Later versions are fixes and enhancements to that.
Important changes from PyGreSQL 2.3 to PyGreSQL 2.4:
- Insert returns None if the user doesn'
t
have
select
permissions
on
the
table
.
It
can
(
and
does
)
happen
that
one
has
insert
but
not
select
permissions
on
a
table
.
-
Added
ntuples
()
method
to
query
object
(
brit
@
druid
.
net
)
-
Corrected
a
bug
related
to
getresult
()
and
the
money
type
-
Corrected
a
but
related
to
negative
money
amounts
-
Allow
update
based
on
primary
key
if
munged
oid
not
available
and
table
has
a
primary
key
-
Add
many
__doc__
strings
.
(
andre
@
via
.
ecp
.
fr
)
Important
changes
from
PyGreSQL
2.2
to
PyGreSQL
2.3
:
Important
changes
from
PyGreSQL
2.2
to
PyGreSQL
2.3
:
-
connect
.
host
returns
"localhost"
when
connected
to
Unix
socket
-
connect
.
host
returns
"localhost"
when
connected
to
Unix
socket
(
torppa
@
tuhnu
.
cutery
.
fi
)
(
torppa
@
tuhnu
.
cutery
.
fi
)
...
...
src/interfaces/python/ChangeLog
View file @
9487ad84
...
@@ -5,6 +5,17 @@ This software is copyright (c) 1995, Pascal Andre (andre@via.ecp.fr)
...
@@ -5,6 +5,17 @@ This software is copyright (c) 1995, Pascal Andre (andre@via.ecp.fr)
Further copyright 1997, 1998 and 1999 by D'Arcy J.M. Cain (darcy@druid.net)
Further copyright 1997, 1998 and 1999 by D'Arcy J.M. Cain (darcy@druid.net)
See file README for copyright information.
See file README for copyright information.
Version 2.4
- Insert returns None if the user doesn't have select permissions
on the table. It can (and does) happen that one has insert but
not select permissions on a table.
- Added ntuples() method to query object (brit@druid.net)
- Corrected a bug related to getresult() and the money type
- Corrected a but related to negative money amounts
- Allow update based on primary key if munged oid not available and
table has a primary key
- Add many __doc__ strings. (andre@via.ecp.fr)
Version 2.3
Version 2.3
- connect.host returns "localhost" when connected to Unix socket
- connect.host returns "localhost" when connected to Unix socket
(torppa@tuhnu.cutery.fi)
(torppa@tuhnu.cutery.fi)
...
...
src/interfaces/python/README
View file @
9487ad84
PyGreSQL
-
v2
.
3
:
PostgreSQL
module
for
Python
PyGreSQL
-
v2
.
4
:
PostgreSQL
module
for
Python
==============================================
==============================================
0.
Copyright
notice
0.
Copyright
notice
===================
===================
PyGreSQL
,
version
2.
3
PyGreSQL
,
version
2.
4
A
Python
interface
for
PostgreSQL
database
.
A
Python
interface
for
PostgreSQL
database
.
Written
by
D
'Arcy J.M. Cain, darcy@druid.net<BR>
Written
by
D
'Arcy J.M. Cain, darcy@druid.net<BR>
Based heavily on code written by Pascal Andre, andre@chimay.via.ecp.fr.
Based heavily on code written by Pascal Andre, andre@chimay.via.ecp.fr.
...
@@ -129,12 +129,13 @@ style prototypes and changed the order of arguments to connect.
...
@@ -129,12 +129,13 @@ style prototypes and changed the order of arguments to connect.
The
home
sites
of
the
different
packages
are
:
The
home
sites
of
the
different
packages
are
:
-
Python
:
ftp
://
ftp
.
python
.
org
:/
pub
/
python
-
Python
:
http
://
www
.
python
.
org
/
-
PosgreSQL
:
ftp
://
ftp
.
PostgreSQL
.
org
/
pub
/
postgresql
-
6.4
.
tar
.
gz
-
PosgreSQL
:
http
://
www
.
PostgreSQL
.
org
/
-
PyGreSQL
:
ftp
://
ftp
.
druid
.
net
/
pub
/
distrib
/
pygresql
-
2.2
.
tgz
-
PyGreSQL
:
http
://
www
.
druid
.
net
/
pygresql
/
A
Linux
RPM
can
be
picked
up
from
ftp
://
www
.
eevolute
.
com
/
pub
/
python
/.
A
Linux
RPM
can
be
picked
up
from
ftp
://
www
.
eevolute
.
com
/
pub
/
python
/.
A
NetBSD
package
thould
be
in
the
distribution
soon
and
is
available
at
ftp
://
ftp
.
druid
.
net
/
pub
/
distrib
/
pygresql
.
pkg
.
tgz
.
1.5
.
Information
and
support
1.5
.
Information
and
support
----------------------------
----------------------------
...
@@ -164,6 +165,10 @@ and all the requests to the database, the pglargeobject that handles
...
@@ -164,6 +165,10 @@ and all the requests to the database, the pglargeobject that handles
all
the
accesses
to
Postgres
large
objects
and
pgqueryobject
that
handles
all
the
accesses
to
Postgres
large
objects
and
pgqueryobject
that
handles
query
results
.
query
results
.
If
you
want
to
see
a
simple
example
of
the
use
of
some
of
these
functions
,
see
http
://
www
.
druid
.
net
/
rides
/
where
I
have
a
link
at
the
bottom
to
the
actual
Python
code
for
the
page
.
2.1
.
pg
module
description
2.1
.
pg
module
description
----------------------------
----------------------------
...
@@ -471,6 +476,16 @@ methods are specified by the tag [LO].
...
@@ -471,6 +476,16 @@ methods are specified by the tag [LO].
type, using a hardcoded table definition. The number returned is the
type, using a hardcoded table definition. The number returned is the
field rank in the result values list.
field rank in the result values list.
2.2.1.5 ntuples - return number of tuples in query object
---------------------------------------------------------
Syntax: ntuples()
Parameters: None
Return type: integer
Description:
This method returns the number of tuples found in a query.
2.2.2. reset - resets the connection
2.2.2. reset - resets the connection
------------------------------------
------------------------------------
...
@@ -847,25 +862,7 @@ The following describes the methods and variables of this class.
...
@@ -847,25 +862,7 @@ The following describes the methods and variables of this class.
Name
of
field
which
is
the
primary
key
of
the
table
.
Name
of
field
which
is
the
primary
key
of
the
table
.
Description
:
Description
:
This
method
returns
the
primary
key
of
a
table
.
Note
that
this
raises
This
method
returns
the
primary
key
of
a
table
.
Note
that
this
raises
an
exception
if
the
table
doesn
't have a primary key. Further, in the
an
exception
if
the
table
doesn
't have a primary key.
currently released implementation of PostgreSQL the '
PRIMARY
KEY
' syntax
doesn'
t
actually
fill
in
the
necessary
tables
to
determine
primary
keys
.
You
can
do
this
yourself
with
the
following
query
.
#
Set
up
table
and
primary_field
variables
...
"""UPDATE pg_index SET indisprimary = 't'
WHERE pg_index.oid in (SELECT pg_index.oid
FROM pg_class, pg_attribute, pg_index
WHERE pg_class.oid = pg_attribute.attrelid AND
pg_class.oid = pg_index.indrelid AND
pg_index.indkey[0] = pg_attribute.attnum AND
pg_class.relname = '%(table)s' AND
pg_attribute.attname = '%(primary_field)');"""
%
locals
()
This
will
be
fixed
in
the
upcoming
6.5
release
of
PostgreSQL
or
you
can
download
the
current
sources
now
.
Downloading
current
is
,
as
usual
,
at
your
own
risk
.
3.3. get_databases - get list of databases in the system
3.3. get_databases - get list of databases in the system
--------------------------------------------------------
--------------------------------------------------------
...
...
src/interfaces/python/pg.py
View file @
9487ad84
...
@@ -25,7 +25,7 @@ def _quote(d, t):
...
@@ -25,7 +25,7 @@ def _quote(d, t):
return
"'f'"
return
"'f'"
if
d
==
""
:
return
"null"
if
d
==
""
:
return
"null"
return
"'
%
s'"
%
string
.
strip
(
re
.
sub
(
'
\'
'
,
'
\'\'
'
,
"
%
s"
%
d
))
return
"'
%
s'"
%
string
.
strip
(
re
.
sub
(
"'"
,
"''"
,
"
%
s"
%
d
))
class
DB
:
class
DB
:
"""This class wraps the pg connection type"""
"""This class wraps the pg connection type"""
...
@@ -175,16 +175,30 @@ class DB:
...
@@ -175,16 +175,30 @@ class DB:
# reload the dictionary to catch things modified by engine
# reload the dictionary to catch things modified by engine
# note that get() changes 'oid' below to oid_table
# note that get() changes 'oid' below to oid_table
return
self
.
get
(
cl
,
a
,
'oid'
)
# if no read perms (it can and does happen) return None
try
:
return
self
.
get
(
cl
,
a
,
'oid'
)
except
:
return
None
# update always works on the oid which get returns
# Update always works on the oid which get returns if available
# otherwise use the primary key. Fail if neither.
def
update
(
self
,
cl
,
a
):
def
update
(
self
,
cl
,
a
):
q
=
"SELECT oid FROM
%
s WHERE oid =
%
s"
%
(
cl
,
a
[
'oid_
%
s'
%
cl
])
foid
=
'oid_
%
s'
%
cl
pk
=
self
.
pkeys
[
cl
]
if
a
.
has_key
(
foid
):
where
=
"oid =
%
s"
%
a
[
foid
]
elif
a
.
has_key
(
pk
):
where
=
"
%
s = '
%
s'"
%
(
pk
,
a
[
pk
])
else
:
raise
error
,
"Update needs key (
%
s) or oid as
%
s"
%
(
pk
,
foid
)
q
=
"SELECT oid FROM
%
s WHERE
%
s"
%
(
cl
,
where
)
if
self
.
debug
!=
None
:
print
self
.
debug
%
q
if
self
.
debug
!=
None
:
print
self
.
debug
%
q
res
=
self
.
db
.
query
(
q
)
.
getresult
()
res
=
self
.
db
.
query
(
q
)
.
getresult
()
if
len
(
res
)
<
1
:
if
len
(
res
)
<
1
:
raise
error
,
"No record in
%
s where oid =
%
s (
%
s)"
%
\
raise
error
,
"No record in
%
s where
%
s (
%
s)"
%
\
(
cl
,
a
[
'oid_
%
s'
%
cl
],
sys
.
exc_value
)
(
cl
,
where
,
sys
.
exc_value
)
else
:
a
[
foid
]
=
res
[
0
][
0
]
v
=
[]
v
=
[]
k
=
0
k
=
0
...
@@ -199,7 +213,7 @@ class DB:
...
@@ -199,7 +213,7 @@ class DB:
try
:
try
:
q
=
"UPDATE
%
s SET
%
s WHERE oid =
%
s"
%
\
q
=
"UPDATE
%
s SET
%
s WHERE oid =
%
s"
%
\
(
cl
,
string
.
join
(
v
,
','
),
a
[
'oid_
%
s'
%
cl
])
(
cl
,
string
.
join
(
v
,
','
),
a
[
foid
])
if
self
.
debug
!=
None
:
print
self
.
debug
%
q
if
self
.
debug
!=
None
:
print
self
.
debug
%
q
self
.
db
.
query
(
q
)
self
.
db
.
query
(
q
)
except
:
except
:
...
...
src/interfaces/python/pgmodule.c
View file @
9487ad84
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment