Re: MySQL help

2005-08-03 Thread [EMAIL PROTECTED]
Hey Dennis thanks for the tips I haven't had a chance to take another
stab at that code yet but I think I may try some of your suggestions.
The SQL statements are valid but something doesn't appear to work right
I may try and switch them to what you're suggesting and see if that
helps with my problem.

Thanks,

-- 
http://mail.python.org/mailman/listinfo/python-list


MySQL help

2005-08-01 Thread [EMAIL PROTECTED]
So i'm writing this program to check if a row exists in a table.  If it
doesn't it inserts it if it does it will update that row with the
current info.

Well it sorta works but not fully.  It goes through and executes the
correct querries but when it comes to determining if the row exists it
doesn't get back a result.  Yet if I mannually enter it into the mysql
console I get a result.  This only happens when my if statement to
determine if there was a result returned is not commented out.  If it
is commented out it returns that the row exists.  Any help would be
great.

Thanks.

here is a snippet of the code assume a cursor has been defined, import
MySQL has occured and the connection have all taken place.

a is the table the query is taking place on.
name is nodeXXX and b is either a 0-3 number.


check=SELECT * FROM +a+ WHERE nodeid='+name+' AND
lid='+b+'
result = cursor.execute(check)
numrows = int(cursor.rowcount)
print numrows:, numrows
cursor = db.cursor()
if numrows == 0:
output=INSERT INTO  +a+ SET nodeid='+name+',
lid='+b+space+, .join(v)
cursor.execute(output)
db.commit()
print Insert
result=''
else:
output=UPDATE +a+ SET nodeid='+name+',
lid='+b+space+, .join(v)
cursor.execute(output)
result=''
db.commit()
print Updating

id.append(int(db.insert_id()))


Thanks,

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MySQL help

2005-08-01 Thread deelan
[EMAIL PROTECTED] wrote:
 So i'm writing this program to check if a row exists in a table.  If it
 doesn't it inserts it if it does it will update that row with the
 current info.

(...)

quick tip: are you aware of the mysql's REPLACE command?
http://dev.mysql.com/doc/mysql/en/replace.html


-- 
deelan, #1 fan of adriana lima!
http://www.deelan.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MySQL help

2005-08-01 Thread [EMAIL PROTECTED]
I wasn't aware of the replace command I'll take a look at that tomorrow
and see if it helps.  Thanks


quick tip: are you aware of the mysql's REPLACE command?
http://dev.mysql.com/doc/mysql /en/replace.html

-- 
http://mail.python.org/mailman/listinfo/python-list