473,387 Members | 1,515 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Insert data quickly into database from GUI

1
Expand|Select|Wrap|Line Numbers
  1. def on_button1_clicked(self, widget, data=None):
  2.         con = MySQLdb.connect('localhost', 'root', 'warriors', 'reg');
  3.         with con:
  4.             cur = con.cursor()
  5.             sql_st="INSERT INTO regg (username, password) VALUES ('ra','%s')"
  6.             cur.execute(sql_st)
  7.             print "It has been inserted successfully "



here the values ra and %s is only inserting in database,but i need a coding for insert statement where the user types in gui application and click insert option tht data only should update..
Dec 19 '12 #1
3 2202
bvdet
2,851 Expert Mod 2GB
You missed an important component of the assignment to sql_st:
Expand|Select|Wrap|Line Numbers
  1. sql_st="INSERT INTO regg (username, password) VALUES ('ra','%s')" % (data)
Dec 19 '12 #2
Rabbit
12,516 Expert Mod 8TB
If you don't want to insert, change your SQL to an insert statement.

If what you actually mean is to do a conditional insert/update depending on if the data is already there. Use an if statement to run different SQL.
Dec 19 '12 #3
dwblas
626 Expert 512MB
You also have to commit for the changes to take place unless auto commit is turned on.
Dec 19 '12 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: c676228 | last post by:
Hi all, I think I have data type problem when I tried to insert data into sql server 200. The erroe message is like this: system.invalidcastexception data type DFlage char(1) in sql 2000, DMI...
2
by: vidyu | last post by:
hai everybody, let me tell you my problem first. I have a table with 300 fields.From front end i have to insert ,delete,update those fields.So at a time i need to enter 300...
1
by: Doc11 | last post by:
I'm trying to allow users insert data into a database using the form view. But when I click the insert button I get this error: Server Error in '/Customer Database' Application....
1
by: rahia307 | last post by:
hi to all i want to use Aajx in php and want to insert data into database. but i have no idea about it. if any one have idea for it please help me
1
by: SuvarnaChaudhari | last post by:
Hi,Plz any one can tell me how to insert data in database through GridView,or there is no way,then plz tell me another way(I mean,should I use DetailView?but how?) Thaknk You!
2
chathura86
by: chathura86 | last post by:
public void insertData(String sql) { if(conn != null) { SqlCommand cmd = new SqlCommand(); cmd.Connection = conn ; //setting the connection to sql command ...
3
by: bobbyze | last post by:
how to insert data into database using php with OOP structure
0
by: ghjk | last post by:
I want to insert web application data to mysql database. I'm using struts, jsp and hibernet.This is my action class. public ActionForward execute(ActionMapping mapping, ActionForm form, ...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.