Skip to main content

Starting adaptor for JSON/Pandas to SQL db

Project description

sqladaptor

Transferring data, stored as JSON or Pandas, into an SQL database and back again.

Why?

Building webserver protoytpes, you will often save your data as JSON or Pandas files. At some point though, you will want to transition to a database where updating/inserting data to disk is more efficient.

SqlAdaptor allows an easy transition to such a database. This includes methods to search using dicts, and to return rows as dicts for web-servers.

This is possible because there is an equivalence between lists of JSON dicts, Pandas DataFrames and SQl tables - they are all tabular arrangements of columnar data.

Installation

pip install sqladaptor

Basic Usage

from sqladaptor.sqlite import SqliteAdaptor
import pandas

entries = [
    {"description": "this", "value": 1},
    {"description": "that", "value": 2}
]

db = SqliteAdaptor('db.sqlite')
db.set_from_df('data1', pandas.DataFrame(entries))

entries = db.get_dict_list('data1')
# [{'description': 'this', 'value': 1}, {'description': 'that', 'value': 2}]

entries = db.get_dict_list('data1', {"description": "this"})
# [{'description': 'this', 'value': 1}]

df = db.get_df("data1", {"value": 2})
#   description  value
# 0        that      2

db.update("data1", {"value": 2}, {"description": "altered"})
entries = db.get_dict_list('data1', {"value": 2})
[{'description': 'altered', 'value': 2}]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sqladaptor-0.1.1.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sqladaptor-0.1.1-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file sqladaptor-0.1.1.tar.gz.

File metadata

  • Download URL: sqladaptor-0.1.1.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.3

File hashes

Hashes for sqladaptor-0.1.1.tar.gz
Algorithm Hash digest
SHA256 217d90587cecd42411471c36bb86aa5ba71bde75b117ac481e8ff38af0da031e
MD5 1461e2454fea56b0d2f7dcea6999952f
BLAKE2b-256 3d390e53b6df64f7613ff4ee44a80cd106f645cfb3401c9ecadfa1ec8f590dbc

See more details on using hashes here.

File details

Details for the file sqladaptor-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: sqladaptor-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.3

File hashes

Hashes for sqladaptor-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ddd4bbce1741df41611acc3eefcf306100af4002728b2ec510e8704e67f00f4f
MD5 5d4ea06c72b2422803e04a126fca94dc
BLAKE2b-256 f730cff74be83d7d35c40a534533f3b3c48f8c97149b3079a4551f4f6834fb6b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page