Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
API reference | Github | PyPI
This is the source repository of the Python SDK for libSQL. You can either connect to a local SQLite database or to a remote libSQL server (sqld).
NOTE: If you want to use libSQL with SQLAlchemy, you should check out the libSQL dialect.
pip install libsql-client
Connecting to a local SQLite database:
import asyncio
import libsql_client
async def main():
url = "file:local.db"
async with libsql_client.create_client(url) as client:
result_set = await client.execute("SELECT * from users")
print(len(result_set.rows), "rows")
for row in result_set.rows:
print(row)
asyncio.run(main())
To connect to a remote libSQL server (sqld), just change the URL:
url = "ws://localhost:8080"
The client can connect to the database using different methods depending on the scheme (protocol) of the passed URL:
file:
connects to a local SQLite database (using the builtin sqlite3
package)
file:/absolute/path
or file:///absolute/path
is an absolute path on local filesystemfile:relative/path
is a relative path on local filesystemfile://path
is not a valid URL)ws:
or wss:
connect to sqld using WebSockets (the Hrana protocol).http:
or https:
connect to sqld using HTTP. The transaction()
API is not available in this case.libsql:
is equivalent to wss:
.This package also provides a synchronous version of the client, which can be created by calling create_client_sync()
. It supports the same methods as the default asyncio
client, except that they block the calling thread:
import libsql_client
url = "file:local.db"
with libsql_client.create_client_sync(url) as client:
result_set = client.execute("SELECT * from users")
print(len(result_set.rows), "rows")
for row in result_set.rows:
print(row)
The synchronous client is just a thin wrapper around the asynchronous client, but it runs the event loop in a background thread.
First, please install Python and Poetry. To install all dependencies for local development to a virtual environment, run:
poetry install --with dev
To run the tests, use:
poetry run pytest
To check types with MyPy, use:
poetry run mypy
This project is licensed under the MIT license.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in libsql-client
by you, shall be licensed as MIT, without any additional terms or conditions.
FAQs
Python SDK for libSQL
We found that libsql-client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.