Skip to content

Commit

Permalink
Merge b9baaee into 59b0e6f
Browse files Browse the repository at this point in the history
  • Loading branch information
jerch committed Apr 13, 2023
2 parents 59b0e6f + b9baaee commit 0b7a16d
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 58 deletions.
59 changes: 13 additions & 46 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: ['3.8', '3.10']
django-version: ['3.2', '4.1']
python-version: ['3.8', '3.11']
django-version: ['3.2', '4.2']
services:
postgres:
image: postgres:latest
Expand All @@ -34,24 +34,10 @@ jobs:
ports: ['6603:3306']
steps:
- uses: actions/checkout@v3
- name: Upgrade sqlite to 3.33
run: |
mkdir sqlite3 && cd sqlite3
wget https://github.com/sqlite/sqlite/archive/refs/tags/version-3.33.0.tar.gz
tar -xf version-3.33.0.tar.gz
cd sqlite-version-3.33.0
./configure --enable-json1 && make
sudo make install
export PATH="/usr/local/lib:$PATH"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Patch SQLITE version
run: |
ldd $(python -c 'import _sqlite3;print(_sqlite3.__file__)')
sudo cp /usr/local/lib/libsqlite3.so.0 /lib/x86_64-linux-gnu/libsqlite3.so.0
python -c 'import sqlite3,sys;print("SQLITE VERSION", sqlite3.sqlite_version_info);sys.exit(1 if sqlite3.sqlite_version_info < (3, 33) else 0)'
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -66,48 +52,29 @@ jobs:
parallel: true
flag-name: Unit Test

test_old:
psycopg3:
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: ['3.8']
django-version: ['3.2']
python-version: ['3.8', '3.11']
services:
mariadb:
image: mariadb:10.2
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: database
ports: ['3306:3306']
mysql:
image: mysql:5.7
postgres:
image: postgres:latest
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: database
ports: ['6603:3306']
POSTGRES_PASSWORD: mysecretpassword
ports: ['5432:5432']
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Check for old SQLITE version
run: |
python -c 'import sqlite3,sys;print("SQLITE VERSION", sqlite3.sqlite_version_info);sys.exit(1 if sqlite3.sqlite_version_info >= (3, 33) else 0)'
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install "Django~=${{ matrix.django-version }}"
pip install -r example/requirements.txt
pip install -r example/requirements-psycopg3.txt
- name: Run Tests
run: |
echo -e "\nTEST: sqlite <3.33"
DBENGINE=sqlite coverage run --parallel-mode --source='fast_update' ./example/manage.py test exampleapp || exit 1
echo -e "\nTEST: mariadb 10.2"
DBENGINE=mysql coverage run --parallel-mode --source='fast_update' ./example/manage.py test exampleapp || exit 1
echo -e "\nTEST: mysql 5.7"
DBENGINE=mysql8 coverage run --parallel-mode --source='fast_update' ./example/manage.py test exampleapp || exit 1
echo -e "\nTEST: postgres with psycopg3"
DBENGINE=postgres coverage run --parallel-mode --source='fast_update' ./example/manage.py test exampleapp || exit 1
DBENGINE=postgres coverage run --parallel-mode --source='fast_update' ./example/manage.py test postgres_tests || exit 1
coverage combine
coverage report
coverage html
Expand All @@ -118,7 +85,7 @@ jobs:
flag-name: Unit Test

coveralls_finish:
needs: [test, test_old]
needs: [test, psycopg3]
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,15 @@ argument (data is always transferred in one big batch). It can be used likewise
**Note** `copy_update` will probably never leave the alpha/PoC-state, as psycopg3 brings great COPY support,
which does a more secure value conversion and has a very fast C-version.

**Note** Django 4.2 brings psycopg3 support, which is currently not yet supported by `copy_update`.
While psycopg2 will keep working as before, psycopg3 will raise on attempts to use `copy_update` until #16 got resolved.


### Status ###

Currently beta, still some TODOs left.

The whole package is tested with Django 3.2 & 4.0 on Python 3.8 & 3.10.
The whole package is tested with Django 3.2 & 4.2 on Python 3.8 & 3.11.


### Performance ###
Expand Down
4 changes: 2 additions & 2 deletions example/postgres_tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from django.db import connection

import unittest
if connection.vendor != 'postgresql':
raise unittest.SkipTest('postgres only tests')
if connection.vendor != 'postgresql' or connection.Database.__version__ > '3':
raise unittest.SkipTest('postgres with pscopg2 only tests')

from django.test import TestCase
from .models import PostgresFields, FieldUpdateNotNull, CustomField, FieldUpdateArray, TestCoverage
Expand Down
5 changes: 5 additions & 0 deletions example/requirements-psycopg3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
coverage==6.2
Django==4.2
psycopg==3.1.8
psycopg-binary==3.1.8
pytz==2022.1
2 changes: 1 addition & 1 deletion example/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
coverage==6.2
coverage==7.2
mysqlclient==2.1.0
psycopg2-binary==2.9.3
pytz==2022.1
Expand Down
2 changes: 1 addition & 1 deletion fast_update/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.2.1'
__version__ = '0.2.2'
4 changes: 2 additions & 2 deletions fast_update/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ def copy_update(
"""
self._for_write = True
connection = connections[self.db]
if connection.vendor != 'postgresql':
if connection.vendor != 'postgresql' or connection.Database.__version__ > '3':
raise NotSupportedError(
f'copy_update() is not supported on "{connection.vendor}" backend')
f'copy_update() only supported on "postgres" backend with psycopg2')
from .copy import copy_update # TODO: better in conditional import?
if not objs:
return 0
Expand Down
9 changes: 5 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def get_version(path):
name='django-fast-update',
packages=find_packages(exclude=['example']),
include_package_data=True,
install_requires=['Django>=3.2,<4.2'],
install_requires=['Django>=3.2,<=4.2'],
version=get_version('fast_update/__init__.py'),
license='MIT',
description='Faster db updates for Django using UPDATE FROM VALUES sql variants.',
Expand All @@ -24,7 +24,7 @@ def get_version(path):
author='netzkolchose',
author_email='j.breitbart@netzkolchose.de',
url='https://github.com/netzkolchose/django-fast-update',
download_url='https://github.com/netzkolchose/django-fast-update/archive/v0.2.1.tar.gz',
download_url='https://github.com/netzkolchose/django-fast-update/archive/v0.2.2.tar.gz',
keywords=['django', 'bulk_update', 'fast', 'update', 'fast_update'],
classifiers=[
'Development Status :: 4 - Beta',
Expand All @@ -34,11 +34,12 @@ def get_version(path):
'Topic :: Software Development :: Libraries',
'Framework :: Django',
'Framework :: Django :: 3.2',
'Framework :: Django :: 4.1',
'Framework :: Django :: 4.2',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10'
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11'
],
)
2 changes: 1 addition & 1 deletion test_all.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

echo -e "\nTEST: sqlite 3.33"
echo -e "\nTEST: sqlite"
DBENGINE=sqlite coverage run --parallel-mode --source='fast_update' ./example/manage.py test exampleapp || exit 1
echo -e "\nTEST: postgres"
DBENGINE=postgres coverage run --parallel-mode --source='fast_update' ./example/manage.py test exampleapp || exit 1
Expand Down

0 comments on commit 0b7a16d

Please sign in to comment.