Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4339612
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T11:14:22+00:00 2026-05-21T11:14:22+00:00

I want to insert the integers 188 and 90 in my MySQL database, but

  • 0

I want to insert the integers 188 and 90 in my MySQL database, but the following code doesn’t work:

import MySQLdb
conn = MySQLdb.connect(host= "localhost",
                  user="root",
                  passwd="newpassword",
                  db="engy1")
x = conn.cursor()
x.execute("SELECT *  FROM anooog1")
x.execute (" INSERT INTO anooog1 VALUES ('%s','%s') ", (188,90))
row = x.fetchall()

Why doesn’t it work?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T11:14:23+00:00Added an answer on May 21, 2026 at 11:14 am
    #Server Connection to MySQL:
    
    import MySQLdb
    conn = MySQLdb.connect(host= "localhost",
                      user="root",
                      passwd="newpassword",
                      db="engy1")
    x = conn.cursor()
    
    try:
       x.execute("""INSERT INTO anooog1 VALUES (%s,%s)""",(188,90))
       conn.commit()
    except:
       conn.rollback()
    
    conn.close()
    

    edit working for me:

    >>> import MySQLdb
    >>> #connect to db
    ... db = MySQLdb.connect("localhost","root","password","testdb" )
    >>> 
    >>> #setup cursor
    ... cursor = db.cursor()
    >>> 
    >>> #create anooog1 table
    ... cursor.execute("DROP TABLE IF EXISTS anooog1")
    __main__:2: Warning: Unknown table 'anooog1'
    0L
    >>> 
    >>> sql = """CREATE TABLE anooog1 (
    ...          COL1 INT,  
    ...          COL2 INT )"""
    >>> cursor.execute(sql)
    0L
    >>> 
    >>> #insert to table
    ... try:
    ...     cursor.execute("""INSERT INTO anooog1 VALUES (%s,%s)""",(188,90))
    ...     db.commit()
    ... except:     
    ...     db.rollback()
    ... 
    1L
    >>> #show table
    ... cursor.execute("""SELECT * FROM anooog1;""")
    1L
    >>> print cursor.fetchall()
    ((188L, 90L),)
    >>> 
    >>> db.close()
    

    table in mysql;

    mysql> use testdb;
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A
    
    Database changed
    mysql> SELECT * FROM anooog1;
    +------+------+
    | COL1 | COL2 |
    +------+------+
    |  188 |   90 |
    +------+------+
    1 row in set (0.00 sec)
    
    mysql> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to insert a record into a MySQL database table from a formulaire.
I want to insert multiple rows with a single insert statement. The following code
As the code Shows below, I want to insert a row into a database
I'm trying to insert an array of 3 digit integers into a MySQL Database
I want insert a custom snippet into an XML file from code within an
I want to insert a date record to an Access database. Here is my
I want to insert the following include tag into my webpage using JavaScript. <!--#include
I want to insert some items to mysql db. When I did it in
I want to insert some phrases to MySQL the first field is english and
I want to insert given text to existing pdf at X,Y location provided. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.