MySQLdb

Kill Joy g.ricioppo at gmail.com
Sun Nov 22 10:03:18 EST 2009


On 22 Nov, 16:00, Gerald Walker <geraldwalk... at gmail.com> wrote:
> Kill Joy wrote:
> > Hi all.
>
> > I have a mod_python script with two query:
>
> >    cursor = db.cursor()
>
> >    sql = 'SELECT * FROM users where username=\'' + username +'\''
> >    cursor.execute(sql)
> >    result = cursor.fetchall()
> >    num =  int(cursor.rowcount)
>
> >    if num == 0 :
> >            sql2 = 'insert into users values (null, \'' + username + '\', \'' +
> > password +'\', \'no\',\'fdfdf\')'
> >            cursor.execute(sql2)
>
>                 db.commit()
>
> >            warning = "Registration ok"
>
> >    else :
> >            warning = "EXIST!"
>
> > The first query is executed... but not the second. It doesn't insert.
> > Why?
> > I'm a newbie... sorry.
>
> > Many thanks.
>
> I added db.commit() after cursor.execute(sql2).

ohhh... many thanks many thanks.

Gius.



More information about the Python-list mailing list