Couchbase dialect for SQLAlchemy to Couchbase Analytics/Columnar. A Python client library for Couchbase Analytics, couchbase-sqlalchemy provides a comprehensive DB-API and SQLAlchemy dialect implementation for Couchbase.
The Couchbase SQLAlchemy package can be installed from the public PyPI repository using pip:
pip install --upgrade couchbase-sqlalchemy
1.Creatge a file (e.g. test.py) that contains the following Python sample code, which connects to Couchbase Analytics and displays a simple locate function query:
import urllib.parse from sqlalchemy import create_engine # Define the Couchbase connection string (replace with your details) URL = 'couchbase://<username>:<password>@<host>:<port>?ssl=false' # Create the engine for Couchbase using the Couchbase SQLAlchemy dialect engine = create_engine(COUCHBASE_URL) query_result = engine.execute("select locate('something','there is something good');") result = query_result.fetchall() print(result)
Replace <your_user_login_name>, <your_password>, and <host> and <port> with the appropriate values for your Couchbase account and user.
Execute the sample code. For example, if you created a file named test.py:
python test.py
Couchbase SQLAlchemy is distributed under the Apache 2.0.