Package: pandas-liteql
What is pandas-liteql?pandas-liteqlis a simplepandasextension that enables users to execute SQL statements against DataFrames using in-memorySQLite. It is meant to streamline data manipulation and analysis tasks. For more detailed information and examples onpandas-liteql, visit thedocumentation pages.What pandas-liteql is notpandas-liteqlis not a competitor to libraries such asPySparkorDuckDBthat can perform SQL queries on larger data sets and perform more advanced data science use-cases. Rather, it is inspired by those projects and similar libraries that have performed the same function, but have since been abandoned or were not as user-friendly.Installing pandas-liteqlpandas-liteqlrequires a minimum of Python 3.7 and the following libraries:LibraryVersionPandas>= 1.3.5SQLAlchemy>= 1.4.36Assuming these prerequisites are already installed, addingpandas-liteqlis as simple as...pip install pandas-liteqlExamplesBelow are some usage examples to load, query, and drop data from the in-memory SQLite sessions established withpandas-liteqland pandas DataFrame integration. For more in-depth information and examples visit thedocumentation pages.LoadingStart by loading your DataFrame with theloadfunction. Whenpandas-liteqlis imported, an in-memory SQLite session is created where data can be loaded to.importpandasaspdimportpandas_liteqlaslql# Data set creationperson_data={'name':['Bill','Ted','Abraham','Genghis','Napoleon'],'age':[25,24,56,64,51],'email':['bill@excellent.com','ted@excellent.com','lincoln@excellent.com','khan@excellent.com','bonaparte@excellent.com']}# DataFrame creationperson_df=pd.DataFrame(data=person_data)# Loading the DataFrame to in-memory SQLite as the 'person' table# The 'person' variable is also a LiteQL class containing the table name and schema informationperson=lql.load(df=person_df,table_name='person')print(f'Table name:{person.name}')print(person.schema)Output:Table name: person
    name    type  nullable default autoincrement  primary_key
0  index  BIGINT      True    None          auto            0
1   name    TEXT      True    None          auto            0
2    age  BIGINT      True    None          auto            0
3  email    TEXT      True    None          auto            0QueryingNext, query the table using thequeryfunction. Using SQL syntax, the loaded table can be queried and the results will be returned as a pandas DataFrame.bill_and_ted=lql.query(sql='SELECT * FROM person WHERE age < 30')print(bill_and_ted)Output:index  name  age               email
0      0  Bill   25  bill@excellent.com
1      1   Ted   24   ted@excellent.comDroppingIf finished with a table within the flow of a script, you can simply drop it with thedropfunction to preserve memory.lql.drop(table_name='person')The DataFrame SQL AccessorLastly, for a more simplistic approach, you can use theliteql.sqlaccessor to perform the same functions above in one line and return the result as a pandas DataFrame. This approach requires that you query from theliteqltable that is loaded from the DataFrame, queried, and then dropped.importpandasaspdimportpandas_liteqlaslql# Data set creationperson_data={'name':['Bill','Ted','Abraham','Genghis','Napoleon'],'age':[25,24,56,64,51],'email':['bill@excellent.com','ted@excellent.com','lincoln@excellent.com','khan@excellent.com','bonaparte@excellent.com']}# DataFrame creationperson_df=pd.DataFrame(data=person_data)bill_and_ted=person_df.liteql.sql('SELECT * FROM liteql WHERE age < 30')print(bill_and_ted)Output:index  name  age               email
0      0  Bill   25  bill@excellent.com
1      1   Ted   24   ted@excellent.comContributingContributions are welcome via pull request from a fork. Log issues if any bugs are found or if you have some good ideas of how this project could be expanded on. Depending on interest, other contributors could be added to meet the demand in features.