msqlite


Namemsqlite JSON
Version 0.3.0 PyPI version JSON
download
home_pageNone
SummaryExecute simple SQLite statements that are multithreaded/multiprocess safe
upload_time2024-03-29 20:31:42
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseMIT License Copyright (c) 2024 James Abel Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords sqlite multithread multiprocess
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # msqlite

Multi-threaded/multi-process support on top of SQLite. The intent is to ensure a SQL statement
will get executed, even if other threads or processes are trying to access the DB. Avoids 
`database is locked` issues. 

No additional package dependencies beyond regular Python.

Intended for relatively simple SQL statement execution. Locks the DB file on every access, with 
built-in retry mechanism.

Even though the DB is locked on every access, typically simple writes are much less than 1 second
(more like 1 mS), so this latency is still usable for many use cases.

```python
    table_name = "example"
    schema = {"id PRIMARY KEY": int, "name": str, "color": str, "year": int}
    db_path = Path("temp", "example.sqlite")
    db_path.parent.mkdir(exist_ok=True)

    # Write and read data.
    with MSQLite(db_path, table_name, schema) as db:
        now = time.monotonic_ns()  # some index value
        # insert some data
        db.execute(f"INSERT INTO {table_name} VALUES ({now}, 'plate', 'red', 2020), ({now + 1}, 'chair', 'green', 2019)")
        # read the data back out
        response = db.execute(f"SELECT * FROM {table_name}")
        for row in response:
            print(row)

    # Read data out. No longer needs the schema.
    with MSQLite(db_path, table_name) as db:
        response = db.execute(f"SELECT * FROM {table_name}")
        for row in response:
            print(row)
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "msqlite",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "sqlite, multithread, multiprocess",
    "author": null,
    "author_email": "James Abel <j@abel.co>",
    "download_url": "https://files.pythonhosted.org/packages/2f/c0/e14e3ed3250deb8c52c9f7eb54afe2be5f0e54995368748b6d3373ca3f07/msqlite-0.3.0.tar.gz",
    "platform": null,
    "description": "# msqlite\r\n\r\nMulti-threaded/multi-process support on top of SQLite. The intent is to ensure a SQL statement\r\nwill get executed, even if other threads or processes are trying to access the DB. Avoids \r\n`database is locked` issues. \r\n\r\nNo additional package dependencies beyond regular Python.\r\n\r\nIntended for relatively simple SQL statement execution. Locks the DB file on every access, with \r\nbuilt-in retry mechanism.\r\n\r\nEven though the DB is locked on every access, typically simple writes are much less than 1 second\r\n(more like 1 mS), so this latency is still usable for many use cases.\r\n\r\n```python\r\n    table_name = \"example\"\r\n    schema = {\"id PRIMARY KEY\": int, \"name\": str, \"color\": str, \"year\": int}\r\n    db_path = Path(\"temp\", \"example.sqlite\")\r\n    db_path.parent.mkdir(exist_ok=True)\r\n\r\n    # Write and read data.\r\n    with MSQLite(db_path, table_name, schema) as db:\r\n        now = time.monotonic_ns()  # some index value\r\n        # insert some data\r\n        db.execute(f\"INSERT INTO {table_name} VALUES ({now}, 'plate', 'red', 2020), ({now + 1}, 'chair', 'green', 2019)\")\r\n        # read the data back out\r\n        response = db.execute(f\"SELECT * FROM {table_name}\")\r\n        for row in response:\r\n            print(row)\r\n\r\n    # Read data out. No longer needs the schema.\r\n    with MSQLite(db_path, table_name) as db:\r\n        response = db.execute(f\"SELECT * FROM {table_name}\")\r\n        for row in response:\r\n            print(row)\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 James Abel  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Execute simple SQLite statements that are multithreaded/multiprocess safe",
    "version": "0.3.0",
    "project_urls": {
        "Source": "https://github.com/jamesabel/msqlite"
    },
    "split_keywords": [
        "sqlite",
        " multithread",
        " multiprocess"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0d641576c07afac0e4d12988b4b57ae02d2ad0f44d77943e2408de987bdbb133",
                "md5": "b333e800aa60012da45da7db105d10b5",
                "sha256": "a06b7179e70f55c5ae9d9fb10ff4b43e623fbf0c73f283a7e4067fa51e0fec4d"
            },
            "downloads": -1,
            "filename": "msqlite-0.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b333e800aa60012da45da7db105d10b5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 5700,
            "upload_time": "2024-03-29T20:31:41",
            "upload_time_iso_8601": "2024-03-29T20:31:41.386648Z",
            "url": "https://files.pythonhosted.org/packages/0d/64/1576c07afac0e4d12988b4b57ae02d2ad0f44d77943e2408de987bdbb133/msqlite-0.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2fc0e14e3ed3250deb8c52c9f7eb54afe2be5f0e54995368748b6d3373ca3f07",
                "md5": "c17406f934cc9c0da4f56fa34b78875d",
                "sha256": "a584658e891a9b05ecfc58cea0abc02c410995e4e48be395eca15ee29f189276"
            },
            "downloads": -1,
            "filename": "msqlite-0.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "c17406f934cc9c0da4f56fa34b78875d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 4731,
            "upload_time": "2024-03-29T20:31:42",
            "upload_time_iso_8601": "2024-03-29T20:31:42.988139Z",
            "url": "https://files.pythonhosted.org/packages/2f/c0/e14e3ed3250deb8c52c9f7eb54afe2be5f0e54995368748b6d3373ca3f07/msqlite-0.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-29 20:31:42",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "jamesabel",
    "github_project": "msqlite",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "msqlite"
}
        
Elapsed time: 0.22499s