AmirPupko / pandas-to-sql

Convert pandas DataFrame manipulations to sql query string
MIT License
45 stars 4 forks source link
not-production-ready pandas python sql

pandas-to-sql

This libaray is not production ready!!

Intro

Convert pandas DataFrame manipulations to sql query string.

Tests

Publish to PyPI

Support:

Try it yourself

>>> import pandas as pd
>>> import pandas_to_sql
>>> iris = pd.read_csv('https://raw.githubusercontent.com/mwaskom/seaborn-data/master/iris.csv')
>>> df = pandas_to_sql.wrap_df(iris,  table_name='iris')
>>> df.get_sql_string()
'SELECT (sepal_length) AS sepal_length, (sepal_width) AS sepal_width, (petal_length) AS petal_length, (petal_width) AS petal_width, (species) AS species FROM iris'
>>> df[df.species == 'setosa'].get_sql_string()
"SELECT (sepal_length) AS sepal_length, (sepal_width) AS sepal_width, (petal_length) AS petal_length, (petal_width) AS petal_width, (species) AS species FROM iris WHERE ((species = 'setosa')) "

Here are some more examples Open In Colab

Installation

pip install pandas-to-sql

Development

Run example

python example_runner.py

Tests

pytest ./pandas_to_sql

Environment

conda env create -f environment.yml --prefix ./env
conda activate ./env
conda env update --prefix ./env -f environment.yml
conda remove --prefix ./env --all

New release

python setup.py sdist bdist_wheel
python -m twine upload --repository pypi --skip-existing dist/*