Connect python with Mysql
Run below command to install package
pip install mysqlconnect
mysql-connector-python must be installed To install it, run below command
pip install mysql-connector-python
from connectdb import mysql_db
ob=mysql_db.sql("host","user","password")
Function db_list is used to show databases list
ob.db_list
Function create_ db is used to create a new database
Parameters
----------
db_name: database name
ob.create_db(Data_base_name)
Function drop_ db is used to drop a database
Parameters
----------
db_name: database name
ob.drop_db(Data_base_name)
Function create_ table is used to create a new table
Parameters
----------
table_name: table name
columns: columns names with data type and other discription in SQL format
example-columns="CI_n INT(2),CI_m INT(2),IAC_u VARCHAR(10),IAC_v VARCHAR(10),IAC_w VARCHAR(10),CAC_u VARCHAR(10),CAC_v VARCHAR(10),CAC_w VARCHAR(10)"
ob.create_table(table_name,columns)
Function insert is used to insert value in table
Parameters
----------
table_name: table name
data: values to be inserted in order
ob.insert(table_name,data)
Function columns is used to print columns names
Parameters
----------
t_name: table name
ob.columns(t_name)
Function select_db is used to select a database
Parameters
----------
db_name: database name
ob.select_db(db_name)
Function query is used to run a SQL query
Parameters
----------
query: SQL query
ob.query(query)
© 2022 Vanshika Panwar
This repository is licensed under the MIT license. See LICENSE for details.