Microsoft One Drive
This documentation describes the integration of MindsDB with Microsoft OneDrive, a cloud storage service that lets you back up, access, edit, share, and sync your files from any device.
Prerequisites
- Before proceeding, ensure that MindsDB is installed locally via Docker or Docker Desktop.
- Register an application in the Azure portal.
- Navigate to the Azure Portal and sign in with your Microsoft account.
- Locate the Microsoft Entra ID service and click on it.
- Click on App registrations and then click on New registration.
- Enter a name for your application and select the
Accounts in this organizational directory only
option for the Supported account types field. - Keep the Redirect URI field empty and click on Register.
- Click on API permissions and then click on Add a permission.
- Select Microsoft Graph and then click on Delegated permissions.
- Search for the
Files.Read
permission and select it. - Click on Add permissions.
- Request an administrator to grant consent for the above permissions. If you are the administrator, click on Grant admin consent for [your organization] and then click on Yes.
- Copy the Application (client) ID and record it as the
client_id
parameter, and copy the Directory (tenant) ID and record it as thetenant_id
parameter. - Click on Certificates & secrets and then click on New client secret.
- Enter a description for your client secret and select an expiration period.
- Click on Add and copy the generated client secret and record it as the
client_secret
parameter. - Click on Authentication and then click on Add a platform.
- Select Web and enter URL where MindsDB has been deployed followed by
/verify-auth
in the Redirect URIs field. For example, if you are running MindsDB locally (onhttps://localhost:47334
), enterhttps://localhost:47334/verify-auth
in the Redirect URIs field.
Connection
Establish a connection to Microsoft OneDrive from MindsDB by executing the following SQL command:
Note that sample parameter values are provided here for reference, and you should replace them with your connection parameters.
Required connection parameters include the following:
client_id
: The client ID of the registered application.client_secret
: The client secret of the registered application.tenant_id
: The tenant ID of the registered application.
Usage
Retrieve data from a specified file in Microsoft OneDrive by providing the integration name and the file name:
Wrap the object key in backticks (`) to avoid any issues parsing the SQL statements provided. This is especially important when the file name contains spaces, special characters or prefixes, such as my-folder/my-file.csv
.
At the moment, the supported file formats are CSV, TSV, JSON, and Parquet.
The above examples utilize one_drive_datasource
as the datasource name, which is defined in the CREATE DATABASE
command.
The special files
table can be used to list the files available in Microsoft OneDrive:
The content of files can also be retrieved by explicitly requesting the content
column. This column is empty by default to avoid unnecessary data transfer:
This table will return all objects regardless of the file format, however, only the supported file formats mentioned above can be queried.
Troubleshooting Guide
Database Connection Error
- Symptoms: Failure to connect MindsDB with Microsoft OneDrive.
- Checklist:
- Ensure the
client_id
,client_secret
andtenant_id
parameters are correctly provided. - Ensure the registered application has the required permissions.
- Ensure the generated client secret is not expired.
- Ensure the
SQL statement cannot be parsed by mindsdb_sql
- Symptoms: SQL queries failing or not recognizing object names containing spaces, special characters or prefixes.
- Checklist:
- Ensure object names with spaces, special characters or prefixes are enclosed in backticks.
- Examples:
- Incorrect: SELECT * FROM integration.travel/travel_data.csv
- Incorrect: SELECT * FROM integration.‘travel/travel_data.csv’
- Correct: SELECT * FROM integration.`travel/travel_data.csv`
Was this page helpful?