Re: [PDO-Users]pdo/pgdb insert
pythondbo-users-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Wed, 21 Jan 2004 08:49:45 +0200
| Newsgroups | gmane.comp.python.db.pdo.user |
|---|---|
| Message-ID | <[email protected]> |
Hi,
Thanks very much for the help!!
Here is the script I'm using, I'm running python 2.3 and
postgresql 7.3.3 compiled with gcc 3.2. For testing it uses
a table called 'users' in db 'vv'(username=postgres,
password=postgres) with 2 fields('username' and
'password'). There is one record('root', 'root')
- Another question, is there any way to get the error
number and message when a exception is raised..
Here is the class file with test statements.
# script start
import pgdb
import pdo
import sys
class database:
host='localhost'
username='postgres'
password='postgres'
db='vv'
def connect(self):
try:
self.dbConnection=pdo.connect("Module=pgdb;user="+self.username+";passwd="+self.password+";db="+self.db)
except pdo.pdo_connection_error:
print "Couldn't connect to
database"
def query(self, statement, param):
try:
result=self.dbConnection.open(statement,
param)
return result
except pdo.pdo_resultset_error:
print "Couldn't get resultset"
def update(self, statement, param):
try:
result=self.dbConnection.execute(statement,
param)
return result
except pdo.pdo_param_execute_error:
print "Couldn't update: "
def close(self):
self.dbConnection.close()
if __name__=="__main__":
db=database()
db.connect()
username="root"
password="root"
statement="select * from users where username=%s
and password=%s"
result=db.query(statement, [username, password])
print result.row_count() # this works with
printing 1
statement="insert into users values ('B', 'B')"
print db.update(statement, line).affected_rows #
this doesn't raise exception and returns None
db.close()
#ends script
Thanks again!!!
Eugene.
On Tue, 20 Jan 2004 11:10:56 -0500
pythondbo-users-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org wrote:
> We'll look into this today - can you give us some more
> info
> so that we can reproduce your setup as much as possible?
>
> ~Jon Franz
> NeuroKode Labs, LLC
>
> ----- Original Message -----
> From: <pythondbo-users-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
> To: <pythondbo-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
> Sent: Tuesday, January 20, 2004 7:16 AM
> Subject: [PDO-Users]pdo/pgdb insert
>
>
> > Hi,
> >
> > I'm sitting with a problem where I can select but not
> > insert/update to a postgresql database using pdo. Here
> is
> > the statement:
> > result=self.dbConnection.execute("insert into users
> values
> > ('B', 'B')")
> > It doesn't raise an exception and if I check
> > result.affected_rows it is 'None'
> > If I execute the statement on the psql command line it
> > works fine and inserts..
> >
> > Thanks for the help...
> > Eugene
> >
> > ___________________________________________
> > Look Good, Feel Good www.healthiest.co.za
> >
> >
> >
> > -------------------------------------------------------
> > The SF.Net email is sponsored by EclipseCon 2004
> > Premiere Conference on Open Tools Development and
> Integration
> > See the breadth of Eclipse activity. February 3-5 in
> Anaheim, CA.
> > http://www.eclipsecon.org/osdn
> > _______________________________________________
> > Pythondbo-users mailing list
> > Pythondbo-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> >
>
https://lists.sourceforge.net/lists/listinfo/pythondbo-users
> >
>
>
> -------------------------------------------------------
> The SF.Net email is sponsored by EclipseCon 2004
> Premiere Conference on Open Tools Development and
> Integration
> See the breadth of Eclipse activity. February 3-5 in
> Anaheim, CA.
> http://www.eclipsecon.org/osdn
> _______________________________________________
> Pythondbo-users mailing list
> Pythondbo-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
>
https://lists.sourceforge.net/lists/listinfo/pythondbo-users
___________________________________________
Look Good, Feel Good www.healthiest.co.za
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn