All Projects → penguinolog → sqlalchemy_jsonfield

penguinolog / sqlalchemy_jsonfield

Licence: Apache-2.0 License
SQLALchemy JSONField implementation for storing dicts at SQL independently from JSON type support

Programming Languages

python
139335 projects - #7 most used programming language
Dockerfile
14818 projects

Projects that are alternatives of or similar to sqlalchemy jsonfield

pykorm
A python 🐍 kubernetes ☸️ ORM 🚀. Very useful when writing operators for your CRDs with Kopf.
Stars: ✭ 56 (+194.74%)
Mutual labels:  sqlalchemy
PythonTwitchBotFramework
asynchronous twitchbot framework made in pure python
Stars: ✭ 78 (+310.53%)
Mutual labels:  sqlalchemy
fastapi-boilerplate
FastAPI boilerplate for real world production
Stars: ✭ 145 (+663.16%)
Mutual labels:  sqlalchemy
fastapi-starter
A FastAPI based low code starter: Async SQLAlchemy, Postgres, React-Admin, pytest and cypress
Stars: ✭ 97 (+410.53%)
Mutual labels:  sqlalchemy
dvhb-hybrid
A package to mix django and asyncio in one application
Stars: ✭ 45 (+136.84%)
Mutual labels:  sqlalchemy
execute-engine
基于Ansible API的任务执行引擎,支持adhoc和playbook两种任务的执行
Stars: ✭ 18 (-5.26%)
Mutual labels:  sqlalchemy
pydbantic
A single model for shaping, creating, accessing, storing data within a Database
Stars: ✭ 137 (+621.05%)
Mutual labels:  sqlalchemy
opentracing-utils
Convenient utilities for adding OpenTracing support in your python projects
Stars: ✭ 20 (+5.26%)
Mutual labels:  sqlalchemy
nebulo
Instant GraphQL API for PostgreSQL and SQLAlchemy
Stars: ✭ 74 (+289.47%)
Mutual labels:  sqlalchemy
reactant
Generate code for "models, views, and urls" based on Python type annotations. Supports Django REST, SQLAlchemy, Peewee.
Stars: ✭ 14 (-26.32%)
Mutual labels:  sqlalchemy
mathesar
Web application providing an intuitive user experience to databases.
Stars: ✭ 95 (+400%)
Mutual labels:  sqlalchemy
flaskbooks
A very light social network & RESTful API for sharing books using flask!
Stars: ✭ 19 (+0%)
Mutual labels:  sqlalchemy
telethon-session-sqlalchemy
SQLAlchemy backend for Telethon session storage
Stars: ✭ 34 (+78.95%)
Mutual labels:  sqlalchemy
bonobo-sqlalchemy
PREVIEW - SQL databases in Bonobo, using sqlalchemy
Stars: ✭ 23 (+21.05%)
Mutual labels:  sqlalchemy
framequery
SQL on dataframes - pandas and dask
Stars: ✭ 63 (+231.58%)
Mutual labels:  sqlalchemy
FinanceCenter
Fetching Financial Data (US/China)
Stars: ✭ 26 (+36.84%)
Mutual labels:  sqlalchemy
carry
Python ETL(Extract-Transform-Load) tool / Data migration tool
Stars: ✭ 115 (+505.26%)
Mutual labels:  sqlalchemy
Resume-Generator
A Resume builder which allows users to build their own custom resumes with details like experience,projects , skills ,education etc. Users can also have the feature to download their resumes . To contribute send PR at development branch from where it will be merged in master once checked.
Stars: ✭ 28 (+47.37%)
Mutual labels:  sqlalchemy
hotpotato
Hotpotato is a space for chefs to display their creations. Follow your favorite chef. Like your favorite recipes. And find the latest gluten-free, vegetarian, and multi-culinary recipes.
Stars: ✭ 13 (-31.58%)
Mutual labels:  sqlalchemy
stream2segment
A Python project to download, process and visualize medium-to-massive amount of seismic waveforms and metadata
Stars: ✭ 18 (-5.26%)
Mutual labels:  sqlalchemy

SQLAlchemy-JSONField

https://travis-ci.com/penguinolog/sqlalchemy_jsonfield.svg?branch=master https://coveralls.io/repos/github/penguinolog/sqlalchemy_jsonfield/badge.svg?branch=master

SQLALchemy JSONField implementation for storing dicts at SQL independently from JSON type support.

Why?

SqlAlchemy provides JSON field support for several database types (PostgreSQL and MySQL for now) and semi-working dict <-> JSON <-> VARCHAR example, but... In real scenarios we have tests on sqlite, production on MySQL/MariaDB/Percona/PostgreSQL and some of them (modern Oracle MySQL & PostgreSQL) support JSON, some of them (SQLite, Percona & MariaDB) requires data conversion to Text (not VARCHAR).

As addition, we have different levels of Unicode support on database and connector side, so we may be interested to switch JSON encoding between deployments.

Note

SQLite 3.9 supports JSON natively and SQLAlchemy can handle this.

Solution:

SQLALchemy JSONField has API with suport for automatic switch between native JSON and JSON encoded data, and encoding to JSON string can be enforced.

Pros:

  • Free software: Apache license
  • Open Source: https://github.com/penguinolog/sqlalchemy_jsonfield
  • Self-documented code: docstrings with types in comments
  • Uses native JSON by default, but allows to specify different library.
  • Support multiple Python versions:
Python 3.5
Python 3.6
Python 3.7
Python 3.8
Python 3.9
PyPy
PyPy3

Usage

Direct usage with MariaDB (example extracted from functional tests):

import sqlalchemy_jsonfield

class ExampleTable(Base):
    __tablename__ = table_name
    id = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True)
    row_name = sqlalchemy.Column(
        sqlalchemy.Unicode(64),
        unique=True,
    )
    json_record = sqlalchemy.Column(
        sqlalchemy_jsonfield.JSONField(
            # MariaDB does not support JSON for now
            enforce_string=True,
            # MariaDB connector requires additional parameters for correct UTF-8
            enforce_unicode=False
        ),
        nullable=False
    )

Usage with alternate JSON library:

import sqlalchemy_jsonfield
import ujson

class ExampleTable(Base):
    __tablename__ = table_name
    id = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True)
    row_name = sqlalchemy.Column(
        sqlalchemy.Unicode(64),
        unique=True,
    )
    json_record = sqlalchemy.Column(
        sqlalchemy_jsonfield.JSONField(
            enforce_string=True,
            enforce_unicode=False,
            json=ujson,  # Use ujson instead of standard json.
        ),
        nullable=False
    )

Usage on PostgreSQL/Oracle MySQL(modern version)/SQLite(testing) environments allows to set enforce_string=False and use native JSON fields.

Testing

The main test mechanism for the package sqlalchemy_jsonfield is using tox. Test environments available:

pep8
py35
py36
py37
py38
pypy3
pylint
docs

CI systems

For code checking several CI systems is used in parallel:

  1. Travis CI: is used for checking: PEP8, pylint, bandit, installation possibility and unit tests. Also it's publishes coverage on coveralls.
  2. coveralls: is used for coverage display.
  3. Circle CI: is used for functional tests at separate docker infrastructure. This CI used for HUGE tests.

CD system

Travis CI: is used for package delivery on PyPI.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].