Sharp Tutorial
Insert Record in a MySQL table using Python

Python

Java

C

C++

HTML/CSS

Java Script

PHP

SQL

C Programs

Introduction to Python

  • Introduction to Python
  • History of Python
  • How To Install Software
  • Variables in Python
  • Comments in Python
  • Input/Output
  • If else in Python
  • While Loop
  • For Loop

Collection in Python

  • Numbers in Python
  • List
  • Tuple
  • Set
  • Dictionary
  • Array
  • String

Object Oriented python

  • Function
  • Exception
  • OOPS (class/object)
  • Object Pass & Return
  • Constructor
  • Function Overloading
  • Module in Python
  • Inheritance
  • File Handling

Python With MYSQL And Excel

  • Connect MySql & Python
  • Insert Data MySQL
  • Delete/Update MySQL
  • Select Data From MySQL
  • Working With Excel in Python

Python GUI

  • GUI using Turtle
  • Introduction to Tkinter
  • Login Page using Tkinter
  • Data Grid Example Tkinter
  • Connect Multiple Forms
  • Database with GUI Python

Programs in Python

  • Swap two number
  • Calculate the area
  • Even Odd or Zero
  • Largest ,Middle and Smallest Number
  • Calculate Telephone Bill
  • Print Table of The given Number
  • Factorial of the number
  • Reverse and check number is palindrome
  • check number is prime , armstrong
  • Program to Print the given patterns
  • Guess A Number Game using Random
Click Here

Sharp (2) Tutorials

Python with database

Watch Video Solution

How to insert data in mysql table using python:

Using python we can insert the data into mysql table . For doing this we must have created the database as previous chapter and then we need to create a table in which we are going to insert the data using python

1 For creating the table following sql query may be used.

 

use sharp_tutorial
create table student (sname varchar(20),course varchar(20) address varchar(20))

Insert the data into MySql table using Python

All previous steps are to be done as install mysql connector , create database and table

 then by using following code we can insert the data into mysql table

import mysql.connector
db=mysql.connector.connect(
host="localhost",
user="root",
password="root",
database="sharp_tutorial")
print("succecssfully connected with database")
MyCursor=db.cursor()
sql="insert into student (sname,course,address) values (%s,%s,%s)"
sname=input("enter the name")
course=input("enter the course")
address=input("enter the address")
val=(sname,course,address)
MyCursor.execute(sql,val)
db.commit()
print("record inserted ")

   Output: Record Inserted

If you check the table in database a record with the given data is being inserted there

Enquiry about Course

Ask your Question

Click Here

Sharp (2) Tutorials

Video/ C Introduction

Watch video in full size

Video tutorial

Follow by Email
Facebook
Facebook
fb-share-icon
YouTube
Copyright © Sharp Tutorial
Build with WordPress
Wordpress Social Share Plugin powered by Ultimatelysocial
Sharp Tutorial