Package: pysql-framework
PySQL is database framework for Python (v3.x) Language, Which is based on Python module mysql.connector, this module can help you to make your code more short and more easier. Before using this framework you must have knowledge about list, tuple, set, dictionary because all codes are designed using it. It's totally free and open source.Tutorial Video in English (Watch Now)InstallationBefore we said that this framework is based on mysql.connector so you have to install mysql.connector first on your system. Then you can import pysql and enjoy coding!python -m pip install mysql-connector-pythonAfter Install mysql.connector successfully create Python file download/install pysql on the same dir where you want to create program. You can clone is using git or npm command, and you can also downlaod manually from repository site.PyPi CommandGo tohttps://pypi.org/project/pysql-framework/or use commandpipinstallpysql-frameworkGit Commandgitclonehttps://github.com/rohit-chouhan/pysqlNpm CommandGo tohttps://www.npmjs.com/package/pysqlor use command$npmipysqlSnippet Extention for VS CodeInstall From Herehttps://marketplace.visualstudio.com/items?itemName=rohit-chouhan.pysqlTable of contentsConnecting a ServerCreate a Database in ServerDrop  DatabaseConnecting a DatabaseCreating Table in DatabaseDrop Table in DatabaseSelecting data from TableAdd New Column to TableModify Column to TableDrop Column from TableManual Execute QueryInserting dataUpdating dataDeleting dataConnecting a ServerTo connect a database with localhost server or phpmyadmin, use connect method to establish your python with database server.importpysqldb=pysql.connect("host","username","password")Create a Database in ServerCreating database in server, to use this methodimportpysqldb=pysql.connect("host","username","password")pysql.createDb(db,"demo")#execute: CREATE DATABASE demoDrop  DatabaseTo drop database use this method .Syntex Code -pysql.dropDb([connect_obj,"table_name"])Example Code -pysql.dropDb([db,"demo"])#execute:DROP DATABASE demoConnecting a DatabaseTo connect a database with localhost server or phpmyadmin, use connect method to establish your python with database server.importpysqldb=pysql.connect("host","username","password","database")Creating Table in DatabaseTo create table in database use this method to pass column name as key and data type as value.Syntex Code -pysql.createTable([db,"table_name_to_create"],{"column_name":"data_type","column_name":"data_type"})Example Code -pysql.createTable([db,"details"],{"id":"int(11) primary","name":"text","email":"varchar(50)","address":"varchar(500)"})2nd Example Code -Use can use any Constraint with Data Valuepysql.createTable([db,"details"],{"id":"int NOT NULL PRIMARY KEY","name":"varchar(20) NOT NULL","email":"varchar(50)","address":"varchar(500)"})Drop Table in DatabaseTo drop table in database use this method .Syntex Code -pysql.dropTable([connect_obj,"table_name"])Example Code -pysql.dropTable([db,"users"])#execute:DROP TABLE usersSelecting data from TableFor Select data from table, you have to mention the connector object with table name. pass column names in set.SyntexFor All Data (*)-records=pysql.selectAll([db,"table_name"])forxinrecords:print(x)Example - -records=pysql.selectAll([db,"details"])forxinrecords:print(x)#execute: SELECT * FROM detailsSyntexFor Specific Column-records=pysql.select([db,"table_name"],{"column","column"})forxinrecords:print(x)Example - -records=pysql.select([db,"details"],{"name","email"})forxinrecords:print(x)#execute: SELECT name, email FROM detailsSyntexWhere and Where Not-#For Where Column=Datarecords=pysql.selectWhere([db,"table_name"],{"column","column"},("column","data"))#For Where Not Column=Data (use ! with column)records=pysql.selectWhere([db,"table_name"],{"column","column"},("column!","data"))forxinrecords:print(x)Example - -records=pysql.selectWhere([db,"details"],{"name","email"},("county","india"))forxinrecords:print(x)#execute: SELECT name, email FROM details WHERE country='india'Add New Column to TableTo add column in table, use this method to pass column name as key and data type as value.
Note: you can only add one column only one callSyntex Code -pysql.addColumn([db,"table_name"],{"column_name":"data_type"})Example Code -pysql.addColumn([db,"details"],{"email":"varchar(50)"})#execute: ALTER TABLE details ADD email varchar(50);Modify Column to TableTo modify data type of column table, use this method to pass column name as key and data type as value.Syntex Code -pysql.modifyColumn([db,"table_name"],{"column_name":"new_data_type"})Example Code -pysql.modifyColumn([db,"details"],{"email":"text"})#execute: ALTER TABLE details MODIFY COLUMN email text;Drop Column from TableNote: you can only add one column only one callSyntex Code -pysql.dropColumn([db,"table_name"],"column_name")Example Code -pysql.dropColumn([db,"details"],"name")#execute: ALTER TABLE details DROP COLUMN nameManual Execute QueryTo execute manual SQL Query to use this method.Syntex Code -pysql.query(connector_object,your_query)Example Code -pysql.query(db,"INSERT INTO users (name) VALUES ('Rohit')")Inserting dataFor Inserting data in database, you have to mention the connector object with table name, and data as sets.Syntex -data={"db_column":"Data for Insert","db_column":"Data for Insert"}pysql.insert([db,"table_name"],data)Example Code -data={"name":"Komal Sharma","contry":"India"}pysql.insert([db,"users"],data)Updating dataFor Update data in database, you have to mention the connector object with table name, and data as tuple.SyntexFor Updating All Data-data=("column","data to update")pysql.updateAll([db,"users"],data)Example - -data=("name","Rohit")pysql.updateAll([db,"users"],data)#execute: UPDATE users SET name='Rohit'SyntexFor Updating Data (Where and Where Not)-data=("column","data to update")#For Where Column=Datawhere=("column","data")#For Where Not Column=Data (use ! with column)where=("column!","data")pysql.update([db,"users"],data,where)Example -data=("name","Rohit")where=("id",1)pysql.update([db,"users"],data,where)#execute: UPDATE users SET name='Rohit' WHERE id=1Deleting dataFor Delete data in database, you have to mention the connector object with table name.SyntexFor Delete All Data-pysql.deleteAll([db,"table_name"])Example - -pysql.deleteAll([db,"users"])#execute: DELETE FROM usersSyntexFor Deleting Data (Where and Where Not)-where=("column","data")pysql.delete([db,"table_name"],where)Example -#For Where Column=Datawhere=("id",1)#For Where Not Column=Data (use ! with column)where=("id!",1)pysql.delete([db,"users"],where)#execute: DELETE FROM users WHERE id=1--- Finish ---Change Logs[19/06/2021]-ConnectSever()removedandmergedtoConnect()-deleteAll()[Fixed]-dropTable()[Added]-dropDb()[Added][20/06/2021]-WhereNotDocs[Added]The module is designed byRohit Chouhan, contact us for any bug report, feature or business inquiry.