Insert data into MySQL table using Python.
Install mysqlclient
Open Terminal or Cmd
cd ~/your-rpoject-folder
virtualenv env
source env/bin/activate
pip install mysql-python
pip install mysqlclient
Then connect your database and insert data
page.py
import mysql.connector
con=mysql.connector.connect(
host="localhost",
user="root",
passwd="",
database = "Your database"
)
cursorT=con.cursor();
email="Dipankar"
upass="12345"
query = "INSERT INTO test1 (uname, upass) VALUES (%s, %s)"
values = (email,upass)
cursorT.execute(query, values)
con.commit()
Run this page
run ~/Desktop/PC_SYSTEM$ python3 page.py
No module named PIL Install PIL module: If you haven't installed PIL yet, install it using pip, the..
Lambda is a small and anonymous function in Python, where you can use many arguments but only ..
Connect with mysql database using python Install the mysql-connector-python-rf - $..
Insert data into MySQL table using Python. Install mysqlclient Open Terminal..
Get the latest news and updates by signing up to our daily newsletter.We won't sell your email or spam you !