Flask-SQLalchemy-Whoosh


NameFlask-SQLalchemy-Whoosh JSON
Version 0.1.3 PyPI version JSON
download
home_page
SummaryA flask extension that adds full text search capabilites to your SQLAlchemy models using the Whoosh search engine
upload_time2023-06-07 19:06:48
maintainer
docs_urlNone
authorNick
requires_python
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Flask-SQLAlchemy-Whoosh
A simple and easy to use Flask extension to add full text search to your SQLAlchemy models using the Whoosh search engine.

### Installing
`$ pip install Flask-SQLAlchemy-Whoosh`

### Setup
```python
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from Flask_SQLalchemy_Whoosh.searcher import WhooshSearcher
from Flask_SQLalchemy_Whoosh.mixin import SearchableMixin

app = Flask(__name__)
db = SQLAlchemy(app)
search = WhooshSearcher(app)
# If you want to use the SearchableMixin
SearchableMixin.init_search(search, db)
```

### Documentation
You can find some documentation [here](https://github.com/Momo8289/Flask-SQLAlchemy-Whoosh/wiki/Docs)

### Example
```python
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from Flask_SQLalchemy_Whoosh.searcher import WhooshSearcher
from Flask_SQLalchemy_Whoosh.mixin import SearchableMixin
from whoosh.fields import ID, TEXT, NUMERIC


app = Flask(__name__)
db = SQLAlchemy(app)
search = WhooshSearcher(app)
SearchableMixin.init_search(search, db)


class Product(SearchableMixin, db.Model):
    __tablename__ = "product"
    # __searchable__ is needed to tell the searcher what to index
    # For documentation on the specifics of each field, refer to the Whoosh documentation
    # https://whoosh.readthedocs.io/en/latest/schema.html
    __searchable__ = {
        "id": ID(stored=True, unique=True),
        "name": TEXT(stored=True),
        "desc": TEXT,
        "price": NUMERIC
    }

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String),
    desc = db.Column(db.String),
    price = db.Column(db.Integer)


# If you want to index a table that  already has entries, use the reindex method
# It will index all entries in the table
Product.reindex()

# Use the search method to search a table
results, total = Product.search("name", "nails")
```




            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "Flask-SQLalchemy-Whoosh",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Nick",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/1e/e3/d0970815c8e2ba81e8ef8c7cb72216d9c937264431be4f92e6f061b8c4ed/flask_sqlalchemy_whoosh-0.1.3.tar.gz",
    "platform": null,
    "description": "# Flask-SQLAlchemy-Whoosh\nA simple and easy to use Flask extension to add full text search to your SQLAlchemy models using the Whoosh search engine.\n\n### Installing\n`$ pip install Flask-SQLAlchemy-Whoosh`\n\n### Setup\n```python\nfrom flask import Flask\nfrom flask_sqlalchemy import SQLAlchemy\nfrom Flask_SQLalchemy_Whoosh.searcher import WhooshSearcher\nfrom Flask_SQLalchemy_Whoosh.mixin import SearchableMixin\n\napp = Flask(__name__)\ndb = SQLAlchemy(app)\nsearch = WhooshSearcher(app)\n# If you want to use the SearchableMixin\nSearchableMixin.init_search(search, db)\n```\n\n### Documentation\nYou can find some documentation [here](https://github.com/Momo8289/Flask-SQLAlchemy-Whoosh/wiki/Docs)\n\n### Example\n```python\nfrom flask import Flask\nfrom flask_sqlalchemy import SQLAlchemy\nfrom Flask_SQLalchemy_Whoosh.searcher import WhooshSearcher\nfrom Flask_SQLalchemy_Whoosh.mixin import SearchableMixin\nfrom whoosh.fields import ID, TEXT, NUMERIC\n\n\napp = Flask(__name__)\ndb = SQLAlchemy(app)\nsearch = WhooshSearcher(app)\nSearchableMixin.init_search(search, db)\n\n\nclass Product(SearchableMixin, db.Model):\n    __tablename__ = \"product\"\n    # __searchable__ is needed to tell the searcher what to index\n    # For documentation on the specifics of each field, refer to the Whoosh documentation\n    # https://whoosh.readthedocs.io/en/latest/schema.html\n    __searchable__ = {\n        \"id\": ID(stored=True, unique=True),\n        \"name\": TEXT(stored=True),\n        \"desc\": TEXT,\n        \"price\": NUMERIC\n    }\n\n    id = db.Column(db.Integer, primary_key=True)\n    name = db.Column(db.String),\n    desc = db.Column(db.String),\n    price = db.Column(db.Integer)\n\n\n# If you want to index a table that  already has entries, use the reindex method\n# It will index all entries in the table\nProduct.reindex()\n\n# Use the search method to search a table\nresults, total = Product.search(\"name\", \"nails\")\n```\n\n\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A flask extension that adds full text search capabilites to your SQLAlchemy models using the Whoosh search engine",
    "version": "0.1.3",
    "project_urls": {
        "Bug Tracker": "https://github.com/Momo8289/Flask-SQLAlchemy-Whoosh/issues",
        "Documentation": "https://github.com/Momo8289/Flask-SQLAlchemy-Whoosh/wiki/Docs",
        "Homepage": "https://github.com/Momo8289/Flask-SQLAlchemy-Whoosh"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5f3b6d5363605e90e2a7419a0c59aa29d51de50fae6e22b0d7f98394c25f09b9",
                "md5": "b65e8f8521074c3ead8469dcc8355f3f",
                "sha256": "bc9aaa8494cad87d25babac07f4a54921eae65e3a0e50d37111afb072331a5cc"
            },
            "downloads": -1,
            "filename": "flask_sqlalchemy_whoosh-0.1.3-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b65e8f8521074c3ead8469dcc8355f3f",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 4737,
            "upload_time": "2023-06-07T19:06:46",
            "upload_time_iso_8601": "2023-06-07T19:06:46.337369Z",
            "url": "https://files.pythonhosted.org/packages/5f/3b/6d5363605e90e2a7419a0c59aa29d51de50fae6e22b0d7f98394c25f09b9/flask_sqlalchemy_whoosh-0.1.3-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1ee3d0970815c8e2ba81e8ef8c7cb72216d9c937264431be4f92e6f061b8c4ed",
                "md5": "9c2d3b9ffb54749c71b2a836aaf7e0a1",
                "sha256": "05104ada2104285427ed561aa1281d86dcfeead2d0d6a472d90fd097c468cd37"
            },
            "downloads": -1,
            "filename": "flask_sqlalchemy_whoosh-0.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "9c2d3b9ffb54749c71b2a836aaf7e0a1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 3751,
            "upload_time": "2023-06-07T19:06:48",
            "upload_time_iso_8601": "2023-06-07T19:06:48.043081Z",
            "url": "https://files.pythonhosted.org/packages/1e/e3/d0970815c8e2ba81e8ef8c7cb72216d9c937264431be4f92e6f061b8c4ed/flask_sqlalchemy_whoosh-0.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-07 19:06:48",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Momo8289",
    "github_project": "Flask-SQLAlchemy-Whoosh",
    "github_not_found": true,
    "lcname": "flask-sqlalchemy-whoosh"
}
        
Elapsed time: 0.09151s