mirror of
				https://github.com/carrotquest/django-clickhouse.git
				synced 2025-11-04 01:47:46 +03:00 
			
		
		
		
	1. Removed six dependency
2. pytz and typing are installed for old python versions only 3. psycopg2-bynary is installed in test environment instead of psycopg2
This commit is contained in:
		
							parent
							
								
									717c74cfd1
								
							
						
					
					
						commit
						893ffaf17c
					
				| 
						 | 
					@ -16,9 +16,8 @@ It is based on [infi.clickhouse-orm](https://github.com/Infinidat/infi.clickhous
 | 
				
			||||||
* [Django](https://docs.djangoproject.com/) 1.7+
 | 
					* [Django](https://docs.djangoproject.com/) 1.7+
 | 
				
			||||||
* [Yandex ClickHouse](https://clickhouse.yandex/)
 | 
					* [Yandex ClickHouse](https://clickhouse.yandex/)
 | 
				
			||||||
* [infi.clickhouse-orm](https://github.com/Infinidat/infi.clickhouse_orm)
 | 
					* [infi.clickhouse-orm](https://github.com/Infinidat/infi.clickhouse_orm)
 | 
				
			||||||
* [pytz](https://pypi.org/project/pytz/)
 | 
					* [pytz](https://pypi.org/project/pytz/) for python before 3.3
 | 
				
			||||||
* [six](https://pypi.org/project/six/)
 | 
					* [typing](https://pypi.org/project/typing/) for python before 3.5
 | 
				
			||||||
* [typing](https://pypi.org/project/typing/)
 | 
					 | 
				
			||||||
* [psycopg2](https://www.psycopg.org/)
 | 
					* [psycopg2](https://www.psycopg.org/)
 | 
				
			||||||
* [celery](http://www.celeryproject.org/)
 | 
					* [celery](http://www.celeryproject.org/)
 | 
				
			||||||
* [statsd](https://pypi.org/project/statsd/)
 | 
					* [statsd](https://pypi.org/project/statsd/)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,11 +1,11 @@
 | 
				
			||||||
Django (>=1.7)
 | 
					 | 
				
			||||||
pytz
 | 
					 | 
				
			||||||
six
 | 
					 | 
				
			||||||
typing
 | 
					 | 
				
			||||||
psycopg2
 | 
					 | 
				
			||||||
infi.clickhouse-orm
 | 
					 | 
				
			||||||
celery
 | 
					celery
 | 
				
			||||||
 | 
					Django (>=1.7)
 | 
				
			||||||
 | 
					infi.clickhouse-orm
 | 
				
			||||||
 | 
					pytz; python_version < '3.3'
 | 
				
			||||||
statsd
 | 
					statsd
 | 
				
			||||||
 | 
					typing; python_version < '3.5'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					psycopg2-binary
 | 
				
			||||||
django-pg-returning
 | 
					django-pg-returning
 | 
				
			||||||
django-pg-bulk-update
 | 
					django-pg-bulk-update
 | 
				
			||||||
redis
 | 
					redis
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,6 @@
 | 
				
			||||||
Django (>=1.7)
 | 
					 | 
				
			||||||
pytz
 | 
					 | 
				
			||||||
six
 | 
					 | 
				
			||||||
typing; python_version < "3.5"
 | 
					 | 
				
			||||||
infi.clickhouse-orm
 | 
					 | 
				
			||||||
celery
 | 
					celery
 | 
				
			||||||
 | 
					Django (>=1.7)
 | 
				
			||||||
 | 
					infi.clickhouse-orm
 | 
				
			||||||
 | 
					pytz; python_version < '3.3'
 | 
				
			||||||
statsd
 | 
					statsd
 | 
				
			||||||
 | 
					typing; python_version < '3.5'
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										2
									
								
								setup.py
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								setup.py
									
									
									
									
									
								
							| 
						 | 
					@ -13,7 +13,7 @@ with open('requirements.txt') as f:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
setup(
 | 
					setup(
 | 
				
			||||||
    name='django-clickhouse',
 | 
					    name='django-clickhouse',
 | 
				
			||||||
    version='1.0.3',
 | 
					    version='1.0.4',
 | 
				
			||||||
    packages=['django_clickhouse'],
 | 
					    packages=['django_clickhouse'],
 | 
				
			||||||
    package_dir={'': 'src'},
 | 
					    package_dir={'': 'src'},
 | 
				
			||||||
    url='https://github.com/carrotquest/django-clickhouse',
 | 
					    url='https://github.com/carrotquest/django-clickhouse',
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,7 +11,6 @@ from typing import List, Tuple, Iterable, Set, Any, Optional
 | 
				
			||||||
from django.db.models import Model as DjangoModel, QuerySet as DjangoQuerySet
 | 
					from django.db.models import Model as DjangoModel, QuerySet as DjangoQuerySet
 | 
				
			||||||
from infi.clickhouse_orm.engines import CollapsingMergeTree
 | 
					from infi.clickhouse_orm.engines import CollapsingMergeTree
 | 
				
			||||||
from infi.clickhouse_orm.models import Model as InfiModel, ModelBase as InfiModelBase
 | 
					from infi.clickhouse_orm.models import Model as InfiModel, ModelBase as InfiModelBase
 | 
				
			||||||
from six import with_metaclass
 | 
					 | 
				
			||||||
from statsd.defaults.django import statsd
 | 
					from statsd.defaults.django import statsd
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from .compatibility import namedtuple
 | 
					from .compatibility import namedtuple
 | 
				
			||||||
| 
						 | 
					@ -41,7 +40,7 @@ class ClickHouseModelMeta(InfiModelBase):
 | 
				
			||||||
        return res
 | 
					        return res
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ClickHouseModel(with_metaclass(ClickHouseModelMeta, InfiModel)):
 | 
					class ClickHouseModel(InfiModel, metaclass=ClickHouseModelMeta):
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
    Base model for all other models
 | 
					    Base model for all other models
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,7 +3,6 @@ from typing import Generator, Optional, Type, Iterable
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from infi.clickhouse_orm.database import Database as InfiDatabase, DatabaseException
 | 
					from infi.clickhouse_orm.database import Database as InfiDatabase, DatabaseException
 | 
				
			||||||
from infi.clickhouse_orm.utils import parse_tsv
 | 
					from infi.clickhouse_orm.utils import parse_tsv
 | 
				
			||||||
from six import next
 | 
					 | 
				
			||||||
from io import BytesIO
 | 
					from io import BytesIO
 | 
				
			||||||
from statsd.defaults.django import statsd
 | 
					from statsd.defaults.django import statsd
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,7 +5,6 @@ It saves all operations to storage in order to write them to ClickHouse later.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from typing import Optional, Any, Type, Set
 | 
					from typing import Optional, Any, Type, Set
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import six
 | 
					 | 
				
			||||||
from django.db import transaction
 | 
					from django.db import transaction
 | 
				
			||||||
from django.db.models import QuerySet as DjangoQuerySet, Model as DjangoModel, Manager as DjangoManager
 | 
					from django.db.models import QuerySet as DjangoQuerySet, Model as DjangoModel, Manager as DjangoManager
 | 
				
			||||||
from django.db.models.manager import BaseManager
 | 
					from django.db.models.manager import BaseManager
 | 
				
			||||||
| 
						 | 
					@ -64,7 +63,7 @@ class ClickHouseSyncBulkUpdateQuerySetMixin(ClickHouseSyncRegisterMixin, BulkUpd
 | 
				
			||||||
        pk_name = self.model._meta.pk.name
 | 
					        pk_name = self.model._meta.pk.name
 | 
				
			||||||
        if returning is None:
 | 
					        if returning is None:
 | 
				
			||||||
            returning = pk_name
 | 
					            returning = pk_name
 | 
				
			||||||
        elif isinstance(returning, six.string_types):
 | 
					        elif isinstance(returning, str):
 | 
				
			||||||
            returning = [pk_name, returning]
 | 
					            returning = [pk_name, returning]
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            returning = list(returning) + [pk_name]
 | 
					            returning = list(returning) + [pk_name]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,7 +4,6 @@ This file defines router to find appropriate database
 | 
				
			||||||
from typing import Type
 | 
					from typing import Type
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import random
 | 
					import random
 | 
				
			||||||
import six
 | 
					 | 
				
			||||||
from infi.clickhouse_orm.migrations import Operation, DropTable, CreateTable
 | 
					from infi.clickhouse_orm.migrations import Operation, DropTable, CreateTable
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from .clickhouse_models import ClickHouseModel
 | 
					from .clickhouse_models import ClickHouseModel
 | 
				
			||||||
| 
						 | 
					@ -47,7 +46,7 @@ class DefaultRouter:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if hints.get('model'):
 | 
					        if hints.get('model'):
 | 
				
			||||||
            model = '%s.%s.%s' % (app_label, config.MODELS_MODULE, hints['model']) \
 | 
					            model = '%s.%s.%s' % (app_label, config.MODELS_MODULE, hints['model']) \
 | 
				
			||||||
                if isinstance(hints['model'], six.string_types) else hints['model']
 | 
					                if isinstance(hints['model'], str) else hints['model']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        model = lazy_class_import(model)
 | 
					        model = lazy_class_import(model)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,7 +11,6 @@ import logging
 | 
				
			||||||
from typing import Any, Optional, List, Tuple
 | 
					from typing import Any, Optional, List, Tuple
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import os
 | 
					import os
 | 
				
			||||||
from six import with_metaclass
 | 
					 | 
				
			||||||
from statsd.defaults.django import statsd
 | 
					from statsd.defaults.django import statsd
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from .configuration import config
 | 
					from .configuration import config
 | 
				
			||||||
| 
						 | 
					@ -152,7 +151,7 @@ class Storage:
 | 
				
			||||||
        raise NotImplemented()
 | 
					        raise NotImplemented()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class RedisStorage(with_metaclass(SingletonMeta, Storage)):
 | 
					class RedisStorage(Storage, metaclass=SingletonMeta):
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
    Fast in-memory storage made on bases of redis and redis-py library.
 | 
					    Fast in-memory storage made on bases of redis and redis-py library.
 | 
				
			||||||
    Requires:
 | 
					    Requires:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,7 +7,6 @@ from itertools import chain
 | 
				
			||||||
from typing import Union, Any, Optional, TypeVar, Set, Dict, Iterable, Tuple, Iterator, Callable, List
 | 
					from typing import Union, Any, Optional, TypeVar, Set, Dict, Iterable, Tuple, Iterator, Callable, List
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import pytz
 | 
					import pytz
 | 
				
			||||||
import six
 | 
					 | 
				
			||||||
from importlib import import_module
 | 
					from importlib import import_module
 | 
				
			||||||
from importlib.util import find_spec
 | 
					from importlib.util import find_spec
 | 
				
			||||||
from django.db.models import Model as DjangoModel
 | 
					from django.db.models import Model as DjangoModel
 | 
				
			||||||
| 
						 | 
					@ -76,7 +75,7 @@ def lazy_class_import(obj: Union[str, Any]) -> Any:
 | 
				
			||||||
    :param obj: A string class path or object to return
 | 
					    :param obj: A string class path or object to return
 | 
				
			||||||
    :return: Imported object
 | 
					    :return: Imported object
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
    if isinstance(obj, six.string_types):
 | 
					    if isinstance(obj, str):
 | 
				
			||||||
        module_name, obj_name = obj.rsplit('.', 1)
 | 
					        module_name, obj_name = obj.rsplit('.', 1)
 | 
				
			||||||
        module = import_module(module_name)
 | 
					        module = import_module(module_name)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,7 +3,6 @@ from queue import Queue
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import pytz
 | 
					import pytz
 | 
				
			||||||
from django.test import TestCase
 | 
					from django.test import TestCase
 | 
				
			||||||
from six import with_metaclass
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
from django_clickhouse.models import ClickHouseSyncModel
 | 
					from django_clickhouse.models import ClickHouseSyncModel
 | 
				
			||||||
from django_clickhouse.utils import get_tz_offset, format_datetime, lazy_class_import, int_ranges, exec_in_parallel, \
 | 
					from django_clickhouse.utils import get_tz_offset, format_datetime, lazy_class_import, int_ranges, exec_in_parallel, \
 | 
				
			||||||
| 
						 | 
					@ -110,7 +109,7 @@ class TestExecInParallel(TestCase):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class TestSingletonMeta(TestCase):
 | 
					class TestSingletonMeta(TestCase):
 | 
				
			||||||
    def test_singleton(self):
 | 
					    def test_singleton(self):
 | 
				
			||||||
        class Single(with_metaclass(SingletonMeta)):
 | 
					        class Single(metaclass=SingletonMeta):
 | 
				
			||||||
            def __init__(self):
 | 
					            def __init__(self):
 | 
				
			||||||
                self.test = 1
 | 
					                self.test = 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user