diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c4312eb --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +.venv + +build/ +dist/ +*.egg-info/ +*.pyc +__pycache__/ diff --git a/README.md b/README.md index 1774910..8119610 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,12 @@ pgsqlite ======= Load SQLite3 databases into PostgreSQL. +Install with pipx + +```sh +pipx install pgsqlite +``` + Usage: ``` usage: pgsqlite.py [-h] -f SQLITE_FILENAME -p POSTGRES_CONNECT_URL [-d DEBUG] [--drop_tables DROP_TABLES] [--drop_everything DROP_EVERYTHING] [--drop_tables_after_import DROP_TABLES_AFTER_IMPORT] diff --git a/install_pypi.sh b/install_pypi.sh index 0eebeab..849699d 100755 --- a/install_pypi.sh +++ b/install_pypi.sh @@ -5,7 +5,7 @@ rm -rf dist/* rm -rf build/* rm -rf pgsqlite.egg-info set -e -pip install wheel bumpversion twine -python setup.py sdist bdist_wheel +pip install build bump-my-version twine +pyproject-build python -m twine check dist/* python -m twine upload --repository-url https://upload.pypi.org/legacy/ dist/* diff --git a/pgsqlite/__main__.py b/pgsqlite/__main__.py new file mode 100644 index 0000000..0b59e97 --- /dev/null +++ b/pgsqlite/__main__.py @@ -0,0 +1,4 @@ +from pgsqlite.pgsqlite import main + +if __name__ == "__main__": + main() diff --git a/pgsqlite/pgsqlite.py b/pgsqlite/pgsqlite.py index 18b2e1c..fde723f 100644 --- a/pgsqlite/pgsqlite.py +++ b/pgsqlite/pgsqlite.py @@ -517,7 +517,7 @@ async def create_all_indexes(): # todo: add checks, views, triggers. -if __name__ == "__main__": +def main(): parser = argparse.ArgumentParser() parser.add_argument( "-f", @@ -586,4 +586,7 @@ async def create_all_indexes(): logger.debug(json.dumps(loader.get_summary(), indent=2)) if args.drop_tables_after_import: - loader._drop_tables() \ No newline at end of file + loader._drop_tables() + +if __name__ == "__main__": + main() diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..b20006d --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,38 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[project] +name = "pgsqlite" +version = "1.0.3" +description = "Loader to import sqlite3 databases into Postgres" + +readme = "README.md" +authors = [ + { name = "bit.io", email = "python@bit.io" } +] + +requires-python = ">=3.9" +dependencies = [ + "sqlite-utils >= 3.28", + "psycopg >= 3.1", + "psycopg-binary >= 3.1", + "structlog >= 22.1.0", + "sqlglot >= 10.6.3" +] + +keywords = ["bit.io", "Database", "postgres", "postgresql", "sqlite", "sqlite3"] +classifiers = [ + "Programming Language :: Python :: 3", + "Operating System :: OS Independent", +] + +[project.urls] +"Homepage" = "https://github.com/bitdotioinc/pgsqlite" +"Bug Tracker" = "https://github.com/bitdotioinc/pgsqlite/issues" + +[project.scripts] +pgsqlite = "pgsqlite.pgsqlite:main" + +[tool.setuptools.packages.find] +exclude = ["test", "tests"] diff --git a/setup.py b/setup.py deleted file mode 100644 index 7c7fad7..0000000 --- a/setup.py +++ /dev/null @@ -1,48 +0,0 @@ -# coding: utf-8 - -""" - pgsqlite - - pgsqlite # noqa: E501 -""" - - -from setuptools import setup, find_packages # noqa: H301 - -NAME = "pgsqlite" -VERSION = "1.0.3" -# To install the library, run the following -# -# python setup.py install -# -# prerequisite: setuptools -# http://pypi.python.org/pypi/setuptools - -REQUIRES = ["sqlite-utils >= 3.28", "psycopg >= 3.1", "psycopg-binary >= 3.1", "structlog >= 22.1.0", "sqlglot >= 10.6.3"] - - -with open("README.md", "r", encoding="utf-8") as fh: - long_description = fh.read() - -setup( - name=NAME, - version=VERSION, - description="Loader to import sqlite3 databases into Postgres", - author="bit.io", - author_email="python@bit.io", - url="https://github.com/bitdotioinc/pgsqlite", - keywords=["bit.io", "Database", "postgres", "postgresql", "sqlite", "sqlite3"], - install_requires=REQUIRES, - packages=find_packages(exclude=["test", "tests"]), - include_package_data=True, - long_description=long_description, - long_description_content_type="text/markdown", - project_urls={ - "Bug Tracker": "https://github.com/bitdotioinc/pgsqlite/issues", - }, - classifiers=[ - "Programming Language :: Python :: 3", - "Operating System :: OS Independent", - ], - python_requires=">=3.9", -)