Skip to main content

Django backend for TiDB

Project description

TiDB dialect for Django

PyPI PyPI - Python Version PyPI - Downloads .github/workflows/ci.yml

This adds compatibility for TiDB to Django.

Installation Guide

Prerequisites

Before installing django-tidb, ensure you have a MySQL driver installed. You can choose either mysqlclient(recommended) or pymysql(at your own risk).

Install mysqlclient (Recommended)

Please refer to the mysqlclient official guide

Install pymysql (At your own risk)

django-tidb has not been tested with pymysql

pip install pymysql

Then add the following code at the beginning of your Django's settings.py:

import pymysql

pymysql.install_as_MySQLdb()

Installing django-tidb

To install django-tidb, you need to select the version that corresponds with your Django version. Please refer to the table below for guidance:

The minor release number of Django doesn't correspond to the minor release number of django-tidb. Use the latest minor release of each.

django django-tidb install command
v4.2.x v4.2.x pip install 'django-tidb>=4.2.0,<4.3.0'
v4.1.x v4.1.x pip install 'django-tidb>=4.1.0,<4.2.0'
v3.2.x v3.2.x pip install 'django-tidb>=3.2.0,<3.3.0'

Usage

Set 'ENGINE': 'django_tidb' in your settings to this:

DATABASES = {
    'default': {
        'ENGINE': 'django_tidb',
        'NAME': 'django',
        'USER': 'root',
        'PASSWORD': '',
        'HOST': '127.0.0.1',
        'PORT': 4000,
    },
}
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
USE_TZ = False
SECRET_KEY = 'django_tests_secret_key'

Supported versions

  • TiDB 4.0 and newer
  • Django 3.2, 4.1 and 4.2
  • Python 3.6 and newer(must match Django's Python version requirement)

Test

create your virtualenv with:

$ virtualenv venv
$ source venv/bin/activate

you can use the command deactivate to exit from the virtual environment.

run all integration tests.

$ DJANGO_VERSION=3.2.12 python run_testing_worker.py

Migrate from previous versions

Releases on PyPi before 3.0.0 are published from repository https://github.com/blacktear23/django_tidb. This repository is a new implementation and released under versions from 3.0.0. No backwards compatibility is ensured. The most significant points are:

  • Only Django 3.2 and 4.0 are tested and supported.
  • Engine name is django_tidb instead of django_tidb.tidb.

Known issues

  • TiDB before v6.6.0 does not support FOREIGN KEY constraints(#18209).
  • TiDB before v6.2.0 does not support SAVEPOINT(#6840).

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

django-tidb-3.2.0.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

django_tidb-3.2.0-py3-none-any.whl (18.8 kB view details)

Uploaded Python 3

File details

Details for the file django-tidb-3.2.0.tar.gz.

File metadata

  • Download URL: django-tidb-3.2.0.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for django-tidb-3.2.0.tar.gz
Algorithm Hash digest
SHA256 d6f45cad9391a84c5a4278d7abec3f05d481e91ef51172a426952a0aba75235b
MD5 564bdfc612604681026d5849043315e2
BLAKE2b-256 a163b6f1dd1ad96636dfa67803801757758323d9ac58062637448945451f0e3d

See more details on using hashes here.

File details

Details for the file django_tidb-3.2.0-py3-none-any.whl.

File metadata

  • Download URL: django_tidb-3.2.0-py3-none-any.whl
  • Upload date:
  • Size: 18.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for django_tidb-3.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 55765c6f7e80c1fa56a82131fd181b79ed872f092ccb4ae72193888289a84c4a
MD5 5020fddda9098975f150b04d404c7b9d
BLAKE2b-256 7d29ed4d82a42defbb1f7800c2fb65dc5e570cd6c5dcf0d74c16c524c97969ab

See more details on using hashes here.

Supported by

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