spark_sql_to_sqlite
Easily save a Spark dataframe into a SQLite database.
Why do you need it
Although you can use jdbc with Spark to write to SQLite, this method is error prone, and doesn't handle complex data types such as Map, Struct and Array.
spark_sql_to_sqlite automatically converts these complex data types to json, which can be used in SQLite queries using standard json functions such as json_extract.
It also has sensible defaults to create or replace the SQLite database and table(s) as needed.
How To Use
You can use this on Spark environments such as Databricks, where you have a spark variable available that represents the SparkContext.
Install it as follows:
%pip install spark-sql-to-sqlite
Then import it as follows:
from spark_sql_to_sqlite import spark_sql_to_sqlite
You can now use it as follows:
spark_sql_to_sqlite("SELECT * from {catalog}.{schema}.{table}", path_to_sqlite_db, table_name)
Example:
spark_sql_to_sqlite(spark, "SELECT * FROM hive_metastore.fire.bronze", "/tmp/fire.db", "bronze")
The above command will create a SQLite database at /tmp/fire.db if it doesn't already exists. It will create or replace the bronze table in this database and overwrite it with the results of the Spark SQL query
Metadata
Release files for spark-sql-to-sqlite 0.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| spark_sql_to_sqlite-0.8.tar.gz | 2.1 kB | Without provenance | Details for spark_sql_to_sqlite-0.8.tar.gz |
Release files / spark_sql_to_sqlite-0.8.tar.gz
| Download URL | spark_sql_to_sqlite-0.8.tar.gz |
|---|---|
| Size | 2.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5f33fed72a03e47000ec1fdd1c3ecdbae8099505c7b1e673e1d6ac595a727af8
|
|
BLAKE2b-256 checksum How to use checksums |
2a92f1e44d2b25d3f89694d8700e1955da66d1530236300978511b4f5871b6f1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.28.1 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.62.3 importlib-metadata/4.8.1 keyring/23.1.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.7
|
Security for spark-sql-to-sqlite 0.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.