{ "info": { "author": "Aviad Rozenhek", "author_email": "aviadr1@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.7", "Topic :: Software Development :: Build Tools" ], "description": "# sqlalchemy_explore\ntools for exploring databases using sqlalchemy\n\n## installation\n\n> ``` \n> pip install sqlalchemy_explore\n> ```\n\n## Features\n\n1. Base class for relective usage of classes\n2. Database exploration tool\n\n## Base class for relective usage of classes\n\n### Usage\n\nMake the declarative base clsss provided by SQLAlchemy derive from `sqlalchemy_explore.ReflectiveMixin`\n\n```python\nimport sqlalchemy_explore\nBase = declarative_base(cls=cls=sqlalchemy_explore.ReflectiveMixin)\n```\n\nnow all of your instances support the following functions:\n* `sa_keys()` - returns the keys/column names that SQLAlchemy is mapping\n* `sa_dict()` - return key/value pairs of all the columns in the object\n* `__repr__()` - str represetation of the object that includes all the columns\n\n### Example\nImagine you have a couple of classes represnting tables in SQLAlchemy \n\n```python\nBase = declarative_base()\n\nclass Artist(Base):\n __tablename__ = 'artists'\n\n ArtistId = Column(Integer, primary_key=True)\n Name = Column(NVARCHAR(120))\n\n\nclass Album(Base):\n __tablename__ = 'albums'\n\n AlbumId = Column(Integer, primary_key=True)\n Title = Column(NVARCHAR(160), nullable=False)\n ArtistId = Column(ForeignKey('artists.ArtistId'), nullable=False, index=True)\n\n artist = relationship('Artist')\n```\n\ndynamiclly iterating through the column names and values of a mapped object requires a lot of boiler plate code.\nbut `sqlalchemy_explore` lets you do this very easily. to enable it on your classes \n\n```python\nimport sqlalchemy_explore\nBase = declarative_base(cls=cls=sqlalchemy_explore.ReflectiveMixin)\n```\n\nand continue having your classes inherit from Base.\n\nnow formatted printing is avaiable to all your objects\n```\nartist = Artist(ArtistId=1, Name='Norah Jones')\nprint('hello', artist)\n```\noutput:\n> `hello Artist(ArtistId=1, Name='Norah Jones')`\n\n```\nalbum = Album(AlbumId=1, Title='Come Away with Me', ArtistId=artist.ArtistId)\nprint('buy', album)\n```\noutput:\n> `buy Album(AlbumId=1, Title='Come Away with Me', ArtistId=1)`\n\nalso you can iterate over a dict of column names/values in your object\n```\nprint(album.sa_dict())\n```\noutput:\n> `{'AlbumId': 1, 'Title': 'Come Away with Me', 'ArtistId': 1}`\n\n\n## Database exploration tool\n\nwhen using sqlalchemy_explore as a tool, it can dump the schema of database tables to help you figure out what's in the DB\n\nAt the minimum, you have to give sqlalchemy_explore a database URL or a path to a local sqlite database. The URL is passed directly to SQLAlchemy\u2019s create_engine() method so please refer to SQLAlchemy\u2019s documentation for instructions on how to construct a proper URL.\n\nExamples:\n\n> ``` \n> python -m sqlalchemy_explore database.db\n> python -m sqlalchemy_explore postgresql:///some_local_db\n> python -m sqlalchemy_explore mysql+oursql://user:password@localhost/dbname\n> python -m sqlalchemy_explore sqlite:///database.db\n> ```", "description_content_type": "text/markdown", "docs_url": null, "download_url": "https://github.com/aviadr1/sqlalchemy-explore/archive/v0.1.tar.gz", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/aviadr1/sqlalchemy-explore", "keywords": "SQLAlchemy,reflect,explore,dump,automap", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "sqlalchemy-explore", "package_url": "https://pypi.org/project/sqlalchemy-explore/", "platform": "", "project_url": "https://pypi.org/project/sqlalchemy-explore/", "project_urls": { "Download": "https://github.com/aviadr1/sqlalchemy-explore/archive/v0.1.tar.gz", "Homepage": "https://github.com/aviadr1/sqlalchemy-explore" }, "release_url": "https://pypi.org/project/sqlalchemy-explore/0.1.2/", "requires_dist": null, "requires_python": "", "summary": "Utilities for working with pre-existing databases using SQLAlchemy", "version": "0.1.2" }, "last_serial": 5486967, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "e90a6b404a8a7eda933da6701d391fa9", "sha256": "8b70ef031446d9fe823b648f6c11d4e02ebdb1157b87117c9d6e4bec4ca76680" }, "downloads": -1, "filename": "sqlalchemy_explore-0.1.tar.gz", "has_sig": false, "md5_digest": "e90a6b404a8a7eda933da6701d391fa9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2302, "upload_time": "2019-07-04T13:09:41", "url": "https://files.pythonhosted.org/packages/96/73/8a33c41a28329dc6ec3a97c2fedd35df31587bf2c36570b46327a1973873/sqlalchemy_explore-0.1.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "c5fd92084a81fcc35dfb026342f9cefc", "sha256": "cad18560b266fae86febd88f1882e4a8a8dc7501b329d5e38036f64125a7d76e" }, "downloads": -1, "filename": "sqlalchemy_explore-0.1.1.tar.gz", "has_sig": false, "md5_digest": "c5fd92084a81fcc35dfb026342f9cefc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2586, "upload_time": "2019-07-04T14:16:10", "url": "https://files.pythonhosted.org/packages/9f/87/3a1c89b9b7117582cb48b7874037805265ef26603b669307756fe332dfc4/sqlalchemy_explore-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "2fde8d21b061821fde2b6152db792b0e", "sha256": "1e020c66d461396abd1864332c14397bc767daa4230b0b67b94b3b4ea49fe341" }, "downloads": -1, "filename": "sqlalchemy_explore-0.1.2.tar.gz", "has_sig": false, "md5_digest": "2fde8d21b061821fde2b6152db792b0e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4335, "upload_time": "2019-07-04T14:31:32", "url": "https://files.pythonhosted.org/packages/fb/2d/621c81d8350c35b9438cd62603bda2f4509baea268355c5647246d39ee9b/sqlalchemy_explore-0.1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "2fde8d21b061821fde2b6152db792b0e", "sha256": "1e020c66d461396abd1864332c14397bc767daa4230b0b67b94b3b4ea49fe341" }, "downloads": -1, "filename": "sqlalchemy_explore-0.1.2.tar.gz", "has_sig": false, "md5_digest": "2fde8d21b061821fde2b6152db792b0e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4335, "upload_time": "2019-07-04T14:31:32", "url": "https://files.pythonhosted.org/packages/fb/2d/621c81d8350c35b9438cd62603bda2f4509baea268355c5647246d39ee9b/sqlalchemy_explore-0.1.2.tar.gz" } ] }