Package: pysqlgui
:zap: PysqlguiPysqlguiis alightweightpackage for interfacing intuitively withSQLin Python.:books: FeaturesRunanyvalid SQL query.Clean andvisually appealingquery results with column names.Import tables fromCSV filesorPandas DataFrames.Easilyrename,create, ordroptables without writinglong and complexqueries.Easily retrieve table information such ascolumn type,default values,null constraints, andkey constraints.Helpfulerror messages.Andmore!:memo: UsageUsing Pysqlgui iseasy!importpysqlgui# Load a file and name the tablestores=pysqlgui.Database(['customers.csv'],['CUSTOMERS'])# Run a querystores.run_query('SELECT * FROM CUSTOMERS;')If you are running code in aJupyter Notebook, the output will be a Pandas DataFrame.  Otherwise, call print on the line above to print out the query result.Note: you can pass other data formats or no data at all!  Refer todetailed documentationbelow.:desktop_computer: InstallationFromPyPi:$pipinstallpysqlgui:book: Quick GuideInstantiate a Database objectand pass any data if you wish.your_database_name=pysqlgui.Database()Then call any of the methods below!MethodSummaryDatabase.run_query(query)Run a SQL query.Database.show(table_name)Show the contents of a table.Database.info(table_name=None)Summary informationabout the database. Pass a table name as an argument to get table information.Database.create_table(table_name, column_data)Create an empty table.Database.add_table(data, table_names=None)Add a tableto the database from a CSV file or Pandas DataFrame.Database.insert_data(table_name, data)Insert data into a table.Database.drop_table(table_name)Drop a table.Database.rename_table(table_name, change_to)Rename a table.:page_facing_up: Detailed DocumentationCreating a databasepysqlgui.Database(data=None,table_names=None,name=None)Parametersdata:list or dict, default=None, OptionalCan be a list (of filepaths to CSVs, or of Pandas DataFrames), or a dict where the key is the table name and the value is the filepath to the CSV or a Pandas DataFrame.table_names:list, default=None, OptionalList of names of the tables, must be provided if data is of type list.name:str, default=None, OptionalName given to the database.importpysqlguiaspsgimportpandasaspd# empty databasedb_example_1=psg.Database()# from csv file via list notationdb_example_2=psg.Database(['customers.csv'],['CUSTOMERS'])# from csv file via dict notationdb_example_3=psg.Database({'CUSTOMERS':'customers.csv'})# from a Pandas DataFramedf=pd.DataFrame({'name':['John','Mary'],'age':[32,18]})db_example_4=psg.Database([df],['USERS'])# from a combinationdb_example_5=psg.Database([df,'customers.csv'],['USERS','CUSTOMERS'])db_example_6=psg.Database({'CUSTOMERS':'customers.csv','USERS':df})Run a SQL querypysqlgui.Database.run_query(self,query:str)Runs a SQL query.Parametersquery:strA SQL query.ReturnsPandas DataFrame, or NoneReturns a Pandas DataFrame if the query is of SELECT or PRAGMA type, None otherwise. Note, all valid SQL is allowed including CREATE, INSERT, DROP, etc.importpysqlguiaspsgimportpandasaspd# SELECT datadf=pd.DataFrame({'name':['John','Mary'],'age':[32,18]})my_db=psg.Database([df],['USERS'])my_db.run_query('SELECT * FROM USERS;')Summary information about the databasepysqlgui.Database.info(table_name=None)Returns summary information about the database or a table.Parameterstable_name:str, default=None, OptionalThe name of the table.  If a name is not provided, returns summary information about the database.ReturnsPandas DataFrameReturns summary database or table information in a Pandas DataFrame.importpysqlguiaspsgimportpandasaspddf=pd.DataFrame({'name':['John','Mary'],'age':[32,18]})my_db=psg.Database([df],['USERS'])my_db.info()# database infomy_db.info('USERS')# table infoCreate an empty tablepysqlgui.Database.create_table(self,table_name,column_data)Creates an empty table in the database. Note: SeeSQLite Datatypes.Parameterstable_name:strThe name of the table to be created.column_data:dictKeys are the column names, and values are the type with any properties.ReturnsNoneimportpysqlguiaspsgimportpandasaspdmy_db=core_database.Database()my_db.create_table('users',{'user_id':'INTEGER','first_name':'TEXT','join_date':'DATE','score':'FLOAT'})# create tables with additional propertiesmy_db_2=core_database.Database()my_db_2.create_table('users',{'user_id':'INTEGER PRIMARY KEY AUTOINCREMENT','first_name':'TEXT','join_date':'DATE'})my_db_2.create_table('articles',{'article_id':'INTEGER PRIMARY KEY','article_name':'TEXT','written_by':'INTEGER REFERENCES users(user_id)'})Add a tablepysqlgui.Database.add_table(self,data,table_names=None)Adds one or more Table objects to the current Database instance.Parametersdata:list or dictCan be a list (of filepaths to CSVs, or of Pandas DataFrames), or a dict where the key is the table name and the value is the filepath to the CSV or a Pandas DataFrame.table_names:list, default=None, OptionalList of names of the tables, must be provided if data is of type list.ReturnsNoneimportpysqlguiaspsgimportpandasaspdmy_db=psg.Database()df=pd.DataFrame({'name':['John','Mary'],'age':[32,18]})my_db.add_table([df],['USERS'])Drop a tablepysqlgui.Database.drop_table(self,table_name)Drops a table in the database.Parameterstable_name:strThe name of the table to be dropped.ReturnsNoneimportpysqlguiaspsgimportpandasaspdmy_db=psg.Database([pd.DataFrame({'name':['John','Mary'],'age':[32,18]})],['USERS'],'MY_DB_NAME')my_db.drop_table('USERS')Rename a tablepysqlgui.Database.rename_table(self,table_name,change_to)Renames a table in the database.Parameterstable_name:strThe name of the table to be renamed.change_to:strThe new name of the table.ReturnsNoneimportpysqlguiaspsgimportpandasaspdmy_db=psg.Database([pd.DataFrame({'name':['John','Mary'],'age':[32,18]})],['USERS'],'MY_DB_NAME')my_db.rename_table('USERS','USERS_NEW_NAME')Complete documentation coming very soon!:gear: DevelopmentPysqlgui is built on thesqlite3standard library.The sqlite3Connection ObjectandCursor Objectis available to you:Database.connectionDatabase.cursorYou can find sample data used for some of the exampleshere.:pencil2: ContributingRaise anissueif you encounter any bugs or would like any features.Completefunction stubs.Writetests. Seeinstructionson how to run tests.Clone the repo$gitclonehttps://github.com/atc2146/pysqlgui.git:copyright: LicenseMITÂ© 2020 Alex Chung