User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Python section within the Software Development category of DaniWeb, a massive community of 427,377 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,038 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Python advertiser: Programming Forums
Views: 352 | Replies: 0
Reply
Join Date: Aug 2007
Posts: 128
Reputation: hacker9801 is on a distinguished road 
Rep Power: 2
Solved Threads: 13
hacker9801 hacker9801 is offline Offline
Junior Poster

help with mysql bindings

  #1  
Feb 16th, 2008
I'm using MySQLdb.

Alright, I'm doing
  1. import MySQLdb as mysql
  2. db = mysql.connect("localhost", "root", "password", "database")
  3. cu = db.cursor()
  4.  
  5. rows = cu.execute("INSERT INTO users (user, pass) VALUES ('test', 'test')")
  6. print "rows affected:", rows
  7.  
  8. cu.close();db.close()

Well, what happens is, it gets executed and prints "rows affected: 1" BUT when I check in my MySQL console no rows are there.

What's the problem? My SQL query is fine, and it works when I do it on the MySQL command line.

EDIT: okay, it works if I add a
  1. db.commit()
. -.-
How can I make it auto-commit? I don't feel like doing that after every query, and my app is always using the same cursor for a long period of time
Last edited by hacker9801 : Feb 16th, 2008 at 1:08 am.
AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Python Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the Python Forum

All times are GMT -4. The time now is 3:59 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC