mindsdb-sdk


Namemindsdb-sdk JSON
Version 3.1.6 PyPI version JSON
download
home_pagehttps://github.com/mindsdb/mindsdb_python_sdk
SummaryMindsDB Python SDK, provides an SDK to use a remote mindsdb instance
upload_time2024-09-25 09:16:50
maintainerNone
docs_urlNone
authorMindsDB Inc
requires_python>=3.6
licenseGPL-3.0
keywords
VCS
bugtrack_url
requirements requests pandas mindsdb-sql docstring-parser tenacity openai sseclient-py validators
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Python MindsDB SDK

The Python MindsDB SDK allows you to connect to a MindsDB server from Python using the HTTP API.

## Installation

```
pip install mindsdb_sdk
```

## Example

### Connecting to the MindsDB server

You can establish a connection to the MindsDB server using the SDK. Here are some examples:

#### Connect to a local MindsDB server

```python
import mindsdb_sdk
con = mindsdb_sdk.connect()
con = mindsdb_sdk.connect('http://127.0.0.1:47334')
```

#### Connect to the MindsDB Cloud

```python
import mindsdb_sdk
con = mindsdb_sdk.connect(login='a@b.com', password='-')
con = mindsdb_sdk.connect('https://cloud.mindsdb.com', login='a@b.com', password='-')
```

####  Connect to a MindsDB Pro server

```python
import mindsdb_sdk
con = mindsdb_sdk.connect('http://<YOUR_INSTANCE_IP>', login='a@b.com', password='-', is_managed=True)
```

## Basic usage

Once connected to the server, you can perform various operations. Here are some examples:

```python
# Get a list of databases
databases = con.databases.list()

# Get a specific database
database = databases[0]  # Database type object

# Perform an SQL query
query = database.query('select * from table1')
print(query.fetch())

# Create a table
table = database.tables.create('table2', query)

# Get a project
project = con.projects.proj

# or use mindsdb project
project = con

# Perform an SQL query within a project
query = project.query('select * from database.table join model1')

# Create a view
view = project.views.create('view1', query=query)

# Get a list of views
views = project.views.list()
view = views[0]
df = view.fetch()

# Get a list of models
models = project.models.list()
model = models[0]

# Use a model for prediction
result_df = model.predict(df)
result_df = model.predict(query)

# Create a model
timeseries_options = {
    'order': 'date',
    'window': 5,
    'horizon': 1
}
model = project.models.create(
    'rentals_model',
    predict='price',
    query=query,
    timeseries_options=timeseries_options
)

# Describe a model
model.describe()
```

You can find more examples in this [Google colab notebook](
https://colab.research.google.com/drive/1QouwAR3saFb9ffthrIs1LSH5COzyQa11#scrollTo=k6IbwsKRPQCR
)

## Examples

https://github.com/mindsdb/mindsdb_python_sdk/tree/staging/examples

## API Documentation

The API documentation for the MindsDB SDK can be found at https://mindsdb.github.io/mindsdb_python_sdk/.

### Generating API docs locally:

```commandline
cd docs
pip install -r requirements.txt
make html
```

The online documentation is automatically updated by pushing changes to the docs branch.


## Testing

To run all the tests for the components, use the following command:

```bash
env PYTHONPATH=./ pytest
```

## Contributing

We welcome contributions to the MindsDB SDK. If you'd like to contribute, please refer to the contribution guidelines for more information.

## License

The MindsDB SDK is licensed under the MIT License. Feel free to use and modify it according to your needs
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/mindsdb/mindsdb_python_sdk",
    "name": "mindsdb-sdk",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": null,
    "author": "MindsDB Inc",
    "author_email": "jorge@mindsdb.com",
    "download_url": "https://files.pythonhosted.org/packages/0a/b8/2cdc237e7cc9a04889128de5bdc45024d6bef3623d6ffe07de7f1bc49b01/mindsdb_sdk-3.1.6.tar.gz",
    "platform": null,
    "description": "# Python MindsDB SDK\n\nThe Python MindsDB SDK allows you to connect to a MindsDB server from Python using the HTTP API.\n\n## Installation\n\n```\npip install mindsdb_sdk\n```\n\n## Example\n\n### Connecting to the MindsDB server\n\nYou can establish a connection to the MindsDB server using the SDK. Here are some examples:\n\n#### Connect to a local MindsDB server\n\n```python\nimport mindsdb_sdk\ncon = mindsdb_sdk.connect()\ncon = mindsdb_sdk.connect('http://127.0.0.1:47334')\n```\n\n#### Connect to the MindsDB Cloud\n\n```python\nimport mindsdb_sdk\ncon = mindsdb_sdk.connect(login='a@b.com', password='-')\ncon = mindsdb_sdk.connect('https://cloud.mindsdb.com', login='a@b.com', password='-')\n```\n\n####  Connect to a MindsDB Pro server\n\n```python\nimport mindsdb_sdk\ncon = mindsdb_sdk.connect('http://<YOUR_INSTANCE_IP>', login='a@b.com', password='-', is_managed=True)\n```\n\n## Basic usage\n\nOnce connected to the server, you can perform various operations. Here are some examples:\n\n```python\n# Get a list of databases\ndatabases = con.databases.list()\n\n# Get a specific database\ndatabase = databases[0]  # Database type object\n\n# Perform an SQL query\nquery = database.query('select * from table1')\nprint(query.fetch())\n\n# Create a table\ntable = database.tables.create('table2', query)\n\n# Get a project\nproject = con.projects.proj\n\n# or use mindsdb project\nproject = con\n\n# Perform an SQL query within a project\nquery = project.query('select * from database.table join model1')\n\n# Create a view\nview = project.views.create('view1', query=query)\n\n# Get a list of views\nviews = project.views.list()\nview = views[0]\ndf = view.fetch()\n\n# Get a list of models\nmodels = project.models.list()\nmodel = models[0]\n\n# Use a model for prediction\nresult_df = model.predict(df)\nresult_df = model.predict(query)\n\n# Create a model\ntimeseries_options = {\n    'order': 'date',\n    'window': 5,\n    'horizon': 1\n}\nmodel = project.models.create(\n    'rentals_model',\n    predict='price',\n    query=query,\n    timeseries_options=timeseries_options\n)\n\n# Describe a model\nmodel.describe()\n```\n\nYou can find more examples in this [Google colab notebook](\nhttps://colab.research.google.com/drive/1QouwAR3saFb9ffthrIs1LSH5COzyQa11#scrollTo=k6IbwsKRPQCR\n)\n\n## Examples\n\nhttps://github.com/mindsdb/mindsdb_python_sdk/tree/staging/examples\n\n## API Documentation\n\nThe API documentation for the MindsDB SDK can be found at https://mindsdb.github.io/mindsdb_python_sdk/.\n\n### Generating API docs locally:\n\n```commandline\ncd docs\npip install -r requirements.txt\nmake html\n```\n\nThe online documentation is automatically updated by pushing changes to the docs branch.\n\n\n## Testing\n\nTo run all the tests for the components, use the following command:\n\n```bash\nenv PYTHONPATH=./ pytest\n```\n\n## Contributing\n\nWe welcome contributions to the MindsDB SDK. If you'd like to contribute, please refer to the contribution guidelines for more information.\n\n## License\n\nThe MindsDB SDK is licensed under the MIT License. Feel free to use and modify it according to your needs",
    "bugtrack_url": null,
    "license": "GPL-3.0",
    "summary": "MindsDB Python SDK, provides an SDK to use a remote mindsdb instance",
    "version": "3.1.6",
    "project_urls": {
        "Download": "https://pypi.org/project/mindsdb-sdk/",
        "Homepage": "https://github.com/mindsdb/mindsdb_python_sdk"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0ab82cdc237e7cc9a04889128de5bdc45024d6bef3623d6ffe07de7f1bc49b01",
                "md5": "c722375e4e933af8ab03c0eb4852103d",
                "sha256": "c744a1ae0b6ff2b0027e5a5d69eda557c53d540d4ed3840784fd011e125b98bf"
            },
            "downloads": -1,
            "filename": "mindsdb_sdk-3.1.6.tar.gz",
            "has_sig": false,
            "md5_digest": "c722375e4e933af8ab03c0eb4852103d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 32976,
            "upload_time": "2024-09-25T09:16:50",
            "upload_time_iso_8601": "2024-09-25T09:16:50.778848Z",
            "url": "https://files.pythonhosted.org/packages/0a/b8/2cdc237e7cc9a04889128de5bdc45024d6bef3623d6ffe07de7f1bc49b01/mindsdb_sdk-3.1.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-25 09:16:50",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mindsdb",
    "github_project": "mindsdb_python_sdk",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "requests",
            "specs": []
        },
        {
            "name": "pandas",
            "specs": [
                [
                    ">=",
                    "1.3.5"
                ]
            ]
        },
        {
            "name": "mindsdb-sql",
            "specs": [
                [
                    "<",
                    "1.0.0"
                ],
                [
                    ">=",
                    "0.17.0"
                ]
            ]
        },
        {
            "name": "docstring-parser",
            "specs": [
                [
                    ">=",
                    "0.7.3"
                ]
            ]
        },
        {
            "name": "tenacity",
            "specs": [
                [
                    ">=",
                    "8.0.1"
                ]
            ]
        },
        {
            "name": "openai",
            "specs": [
                [
                    ">=",
                    "1.15.0"
                ]
            ]
        },
        {
            "name": "sseclient-py",
            "specs": [
                [
                    ">=",
                    "1.8.0"
                ]
            ]
        },
        {
            "name": "validators",
            "specs": [
                [
                    "==",
                    "0.20.0"
                ]
            ]
        }
    ],
    "lcname": "mindsdb-sdk"
}
        
Elapsed time: 0.44956s