Skip to content

sqlitecloud/python

Repository files navigation

Python SDK for SQLite Cloud

SQLite Cloud logo

Build Status codecov PyPI - Version PyPI - Downloads PyPI - Python Version

SQLiteCloud is a powerful Python package that allows you to interact with the SQLite Cloud backend server seamlessly. It provides methods for various database operations. This package is designed to simplify database operations in Python applications, making it easier than ever to work with SQLite Cloud.

Installation

You can install SqliteCloud Package using Python Package Index (PYPI):

$ pip install sqlitecloud

Usage


from sqlitecloud.client import SqliteCloudClient
from sqlitecloud.types import SqliteCloudAccount

Init a connection

Using explicit configuration

account = SqliteCloudAccount(user, password, host, db_name, port)
client = SqliteCloudClient(cloud_account=account)
conn = client.open_connection()

Using string configuration

account = SqliteCloudAccount("sqlitecloud://user:pass@host.com:port/dbname?apikey=myapikey")
client = SqliteCloudClient(cloud_account=account)
conn = client.open_connection()

Execute a query

You can bind values to parametric queries: you can pass parameters as positional values in an array

result = client.exec_query(
    "SELECT * FROM table_name WHERE id = 1"
    conn=conn
)

Iterate result

result is an iterable object

for row in result:
    print(row)

Specific value

result.get_value(0, 0)

Column name

result.get_name(0)

Close connection

client.disconnect(conn)