python-mobilitydb


Namepython-mobilitydb JSON
Version 0.1.3 PyPI version JSON
download
home_pagehttps://github.com/MobilityDB/MobilityDB-python
SummaryA database adapter to access MobilityDB from Python
upload_time2023-04-12 13:33:39
maintainer
docs_urlNone
authorMobilityDB Project
requires_python
licenseMIT
keywords mobilitydb python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            # MobilityDB-python
MobilityDB-python is a database adapter to access [MobilityDB](https://github.com/MobilityDB/MobilityDB) from Python. It supports both the [psycopg2](https://github.com/psycopg/psycopg2) and the [asyncpg](https://github.com/MagicStack/asyncpg) adapters for PostgreSQL and uses the [postgis](https://github.com/tilery/python-postgis) adapter for PostGIS.

## Deprecation Notice :warning:
This package is no longer maintained. Instead, we recommend using the [PyMEOS package](https://pypi.org/project/pymeos/), 
which provides a Python interface to the MEOS C library, which is the underlying library of MobilityDB.

Install
------------
```sh
pip install python-mobilitydb
```

Requirements
------------
 - Python >= 3.0
 - MobilityDB

Basic Usage
------------

Using the psycopg2 adapter for PostgreSQL

```python
import psycopg2
from mobilitydb.psycopg import register

connection = None

try:
    # Set the connection parameters to PostgreSQL
    connection = psycopg2.connect(host='localhost', database='test', user='user', password='pw')
    connection.autocommit = True

    # Register MobilityDB data types
    register(connection)

    # Open a cursor to perform database operations
    cursor = connection.cursor()

    # Query the database and obtain data as Python objects
    select_query = "SELECT * FROM tbl_tfloatseq ORDER BY k LIMIT 10"
    cursor.execute(select_query)
    rows = cursor.fetchall()

    # Print the obtained rows and call a method on the instances
    for row in rows:
        print("key =", row[0])
        print("tfloatseq =", row[1])
        if not row[1]:
            print("")
        else:
            print("startTimestamp =", row[1].startTimestamp.isoformat(), "\n")

except (Exception, psycopg2.Error) as error:
    print("Error while connecting to PostgreSQL", error)

finally:
    # Close the connection
    if connection:
        connection.close()
```

Using the asyncg adapter for PostgreSQL

```python
import asyncio
import asyncpg
from mobilitydb.asyncpg import register


async def run():
    # Connect to an existing database
    connection = await asyncpg.connect(host='localhost', database='test', user='user', password='pw')

    try:
        # Register MobilityDB data types
        await register(connection)

        # Query the database and obtain data as Python objects
        select_query = "SELECT * FROM tbl_tgeompointseq ORDER BY k LIMIT 10"
        rows = await connection.fetch(select_query)

        # Print the obtained rows and call a method on the instances
        for row in rows:
            print("key =", row[0])
            print("tgeompointseq =", row[1])
            if not row[1]:
                print("")
            else:
                print("startTimestamp =", row[1].startTimestamp.isoformat(), "\n")
    finally:
        # Close the connection
        await connection.close()

# Launch the process
loop = asyncio.get_event_loop()
loop.run_until_complete(run())
```

Manual
------

HTML: https://docs.mobilitydb.com/MobilityDB-python/master/

PDF: https://docs.mobilitydb.com/MobilityDB-python/master/python-mobilitydb.pdf

EPUB: https://docs.mobilitydb.com/MobilityDB-python/master/python-mobilitydb.epub

Contributing
------------

[Issues](https://github.com/MobilityDB/MobilityDB-python/issues) and [Pull Requests](https://github.com/MobilityDB/MobilityDB-python/pulls) are welcome.

Related Project
---------------

[MobilityDB SQLAlchemy](https://github.com/adonmo/mobilitydb-sqlalchemy) is another package that provides extensions to [SQLAlchemy](https://www.sqlalchemy.org/) for interacting with [MobilityDB](https://github.com/MobilityDB/MobilityDB). 

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/MobilityDB/MobilityDB-python",
    "name": "python-mobilitydb",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "MobilityDB,Python",
    "author": "MobilityDB Project",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/19/75/be4a37c859a6ef7258f0fe3d0c49fdab891a0edbd93239bdc5e1c4bee613/python-mobilitydb-0.1.3.tar.gz",
    "platform": "linux",
    "description": "# MobilityDB-python\r\nMobilityDB-python is a database adapter to access [MobilityDB](https://github.com/MobilityDB/MobilityDB) from Python. It supports both the [psycopg2](https://github.com/psycopg/psycopg2) and the [asyncpg](https://github.com/MagicStack/asyncpg) adapters for PostgreSQL and uses the [postgis](https://github.com/tilery/python-postgis) adapter for PostGIS.\r\n\r\n## Deprecation Notice :warning:\r\nThis package is no longer maintained. Instead, we recommend using the [PyMEOS package](https://pypi.org/project/pymeos/), \r\nwhich provides a Python interface to the MEOS C library, which is the underlying library of MobilityDB.\r\n\r\nInstall\r\n------------\r\n```sh\r\npip install python-mobilitydb\r\n```\r\n\r\nRequirements\r\n------------\r\n - Python >= 3.0\r\n - MobilityDB\r\n\r\nBasic Usage\r\n------------\r\n\r\nUsing the psycopg2 adapter for PostgreSQL\r\n\r\n```python\r\nimport psycopg2\r\nfrom mobilitydb.psycopg import register\r\n\r\nconnection = None\r\n\r\ntry:\r\n    # Set the connection parameters to PostgreSQL\r\n    connection = psycopg2.connect(host='localhost', database='test', user='user', password='pw')\r\n    connection.autocommit = True\r\n\r\n    # Register MobilityDB data types\r\n    register(connection)\r\n\r\n    # Open a cursor to perform database operations\r\n    cursor = connection.cursor()\r\n\r\n    # Query the database and obtain data as Python objects\r\n    select_query = \"SELECT * FROM tbl_tfloatseq ORDER BY k LIMIT 10\"\r\n    cursor.execute(select_query)\r\n    rows = cursor.fetchall()\r\n\r\n    # Print the obtained rows and call a method on the instances\r\n    for row in rows:\r\n        print(\"key =\", row[0])\r\n        print(\"tfloatseq =\", row[1])\r\n        if not row[1]:\r\n            print(\"\")\r\n        else:\r\n            print(\"startTimestamp =\", row[1].startTimestamp.isoformat(), \"\\n\")\r\n\r\nexcept (Exception, psycopg2.Error) as error:\r\n    print(\"Error while connecting to PostgreSQL\", error)\r\n\r\nfinally:\r\n    # Close the connection\r\n    if connection:\r\n        connection.close()\r\n```\r\n\r\nUsing the asyncg adapter for PostgreSQL\r\n\r\n```python\r\nimport asyncio\r\nimport asyncpg\r\nfrom mobilitydb.asyncpg import register\r\n\r\n\r\nasync def run():\r\n    # Connect to an existing database\r\n    connection = await asyncpg.connect(host='localhost', database='test', user='user', password='pw')\r\n\r\n    try:\r\n        # Register MobilityDB data types\r\n        await register(connection)\r\n\r\n        # Query the database and obtain data as Python objects\r\n        select_query = \"SELECT * FROM tbl_tgeompointseq ORDER BY k LIMIT 10\"\r\n        rows = await connection.fetch(select_query)\r\n\r\n        # Print the obtained rows and call a method on the instances\r\n        for row in rows:\r\n            print(\"key =\", row[0])\r\n            print(\"tgeompointseq =\", row[1])\r\n            if not row[1]:\r\n                print(\"\")\r\n            else:\r\n                print(\"startTimestamp =\", row[1].startTimestamp.isoformat(), \"\\n\")\r\n    finally:\r\n        # Close the connection\r\n        await connection.close()\r\n\r\n# Launch the process\r\nloop = asyncio.get_event_loop()\r\nloop.run_until_complete(run())\r\n```\r\n\r\nManual\r\n------\r\n\r\nHTML: https://docs.mobilitydb.com/MobilityDB-python/master/\r\n\r\nPDF: https://docs.mobilitydb.com/MobilityDB-python/master/python-mobilitydb.pdf\r\n\r\nEPUB: https://docs.mobilitydb.com/MobilityDB-python/master/python-mobilitydb.epub\r\n\r\nContributing\r\n------------\r\n\r\n[Issues](https://github.com/MobilityDB/MobilityDB-python/issues) and [Pull Requests](https://github.com/MobilityDB/MobilityDB-python/pulls) are welcome.\r\n\r\nRelated Project\r\n---------------\r\n\r\n[MobilityDB SQLAlchemy](https://github.com/adonmo/mobilitydb-sqlalchemy) is another package that provides extensions to [SQLAlchemy](https://www.sqlalchemy.org/) for interacting with [MobilityDB](https://github.com/MobilityDB/MobilityDB). \r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A database adapter to access MobilityDB from Python",
    "version": "0.1.3",
    "split_keywords": [
        "mobilitydb",
        "python"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fe53328d2cf993905f5e524389f8cd2ab90b546ffe5f088c4344894b7c78ee49",
                "md5": "8bd8c2e1f2862f5e4e989a008abfe930",
                "sha256": "5c3f60b9e79bf4cacec566dafc8afe11a9ffc918689e221bd9594fb7623f2438"
            },
            "downloads": -1,
            "filename": "python_mobilitydb-0.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8bd8c2e1f2862f5e4e989a008abfe930",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 133267,
            "upload_time": "2023-04-12T13:33:37",
            "upload_time_iso_8601": "2023-04-12T13:33:37.246095Z",
            "url": "https://files.pythonhosted.org/packages/fe/53/328d2cf993905f5e524389f8cd2ab90b546ffe5f088c4344894b7c78ee49/python_mobilitydb-0.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1975be4a37c859a6ef7258f0fe3d0c49fdab891a0edbd93239bdc5e1c4bee613",
                "md5": "ff081e78a49418513384d6458e25ea14",
                "sha256": "c161f1e0c15929115da1f6a9f42589350bb3d8835bd4e8ea3c4d5cd437385313"
            },
            "downloads": -1,
            "filename": "python-mobilitydb-0.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "ff081e78a49418513384d6458e25ea14",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 53175,
            "upload_time": "2023-04-12T13:33:39",
            "upload_time_iso_8601": "2023-04-12T13:33:39.825465Z",
            "url": "https://files.pythonhosted.org/packages/19/75/be4a37c859a6ef7258f0fe3d0c49fdab891a0edbd93239bdc5e1c4bee613/python-mobilitydb-0.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-12 13:33:39",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "MobilityDB",
    "github_project": "MobilityDB-python",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": false,
    "lcname": "python-mobilitydb"
}
        
Elapsed time: 0.22136s