Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import django
from django.conf import settings
try:
from django.apps import apps as django_apps
except ImportError:
from django.db.models.loading import AppCache
django_apps = AppCache()
from aldjemy.types import simple, foreign_key, varchar
from aldjemy import postgres
DATA_TYPES = {
'AutoField': simple(types.Integer),
'BigAutoField': simple(types.BigInteger),
'BooleanField': simple(types.Boolean),
'CharField': varchar,
'CommaSeparatedIntegerField': varchar,
'DateField': simple(types.Date),
'DateTimeField': simple(types.DateTime),
'DecimalField': lambda x: types.Numeric(scale=x.decimal_places,
precision=x.max_digits),
'DurationField': simple(types.Interval),
'FileField': varchar,
'FilePathField': varchar,
'FloatField': simple(types.Float),
'IntegerField': simple(types.Integer),
'BigIntegerField': simple(types.BigInteger),
'IPAddressField': lambda field: types.CHAR(length=15),
'NullBooleanField': simple(types.Boolean),
'OneToOneField': foreign_key,
DATA_TYPES = {
'AutoField': simple(types.Integer),
'BigAutoField': simple(types.BigInteger),
'BooleanField': simple(types.Boolean),
'CharField': varchar,
'CommaSeparatedIntegerField': varchar,
'DateField': simple(types.Date),
'DateTimeField': simple(types.DateTime),
'DecimalField': lambda x: types.Numeric(scale=x.decimal_places,
precision=x.max_digits),
'DurationField': simple(types.Interval),
'FileField': varchar,
'FilePathField': varchar,
'FloatField': simple(types.Float),
'IntegerField': simple(types.Integer),
'BigIntegerField': simple(types.BigInteger),
'IPAddressField': lambda field: types.CHAR(length=15),
'NullBooleanField': simple(types.Boolean),
'OneToOneField': foreign_key,
'ForeignKey': foreign_key,
'PositiveIntegerField': simple(types.Integer),
'PositiveSmallIntegerField': simple(types.SmallInteger),
'SlugField': varchar,
'SmallIntegerField': simple(types.SmallInteger),
'TextField': simple(types.Text),
'TimeField': simple(types.Time),
}
# Update with dialect specific data types
'DurationField': simple(types.Interval),
'FileField': varchar,
'FilePathField': varchar,
'FloatField': simple(types.Float),
'IntegerField': simple(types.Integer),
'BigIntegerField': simple(types.BigInteger),
'IPAddressField': lambda field: types.CHAR(length=15),
'NullBooleanField': simple(types.Boolean),
'OneToOneField': foreign_key,
'ForeignKey': foreign_key,
'PositiveIntegerField': simple(types.Integer),
'PositiveSmallIntegerField': simple(types.SmallInteger),
'SlugField': varchar,
'SmallIntegerField': simple(types.SmallInteger),
'TextField': simple(types.Text),
'TimeField': simple(types.Time),
}
# Update with dialect specific data types
DATA_TYPES['ArrayField'] = lambda field: postgres.array_type(DATA_TYPES, field)
# Update with user specified data types
DATA_TYPES.update(getattr(settings, 'ALDJEMY_DATA_TYPES', {}))
def get_django_models():
return django_apps.get_models()
def get_all_django_models():
'DecimalField': lambda x: types.Numeric(scale=x.decimal_places,
precision=x.max_digits),
'DurationField': simple(types.Interval),
'FileField': varchar,
'FilePathField': varchar,
'FloatField': simple(types.Float),
'IntegerField': simple(types.Integer),
'BigIntegerField': simple(types.BigInteger),
'IPAddressField': lambda field: types.CHAR(length=15),
'NullBooleanField': simple(types.Boolean),
'OneToOneField': foreign_key,
'ForeignKey': foreign_key,
'PositiveIntegerField': simple(types.Integer),
'PositiveSmallIntegerField': simple(types.SmallInteger),
'SlugField': varchar,
'SmallIntegerField': simple(types.SmallInteger),
'TextField': simple(types.Text),
'TimeField': simple(types.Time),
}
# Update with dialect specific data types
DATA_TYPES['ArrayField'] = lambda field: postgres.array_type(DATA_TYPES, field)
# Update with user specified data types
DATA_TYPES.update(getattr(settings, 'ALDJEMY_DATA_TYPES', {}))
def get_django_models():
return django_apps.get_models()
except ImportError:
from django.db.models.loading import AppCache
django_apps = AppCache()
from aldjemy.types import simple, foreign_key, varchar
from aldjemy import postgres
DATA_TYPES = {
'AutoField': simple(types.Integer),
'BigAutoField': simple(types.BigInteger),
'BooleanField': simple(types.Boolean),
'CharField': varchar,
'CommaSeparatedIntegerField': varchar,
'DateField': simple(types.Date),
'DateTimeField': simple(types.DateTime),
'DecimalField': lambda x: types.Numeric(scale=x.decimal_places,
precision=x.max_digits),
'DurationField': simple(types.Interval),
'FileField': varchar,
'FilePathField': varchar,
'FloatField': simple(types.Float),
'IntegerField': simple(types.Integer),
'BigIntegerField': simple(types.BigInteger),
'IPAddressField': lambda field: types.CHAR(length=15),
'NullBooleanField': simple(types.Boolean),
'OneToOneField': foreign_key,
'ForeignKey': foreign_key,
'PositiveIntegerField': simple(types.Integer),
'PositiveSmallIntegerField': simple(types.SmallInteger),
'SlugField': varchar,
'SmallIntegerField': simple(types.SmallInteger),
precision=x.max_digits),
'DurationField': simple(types.Interval),
'FileField': varchar,
'FilePathField': varchar,
'FloatField': simple(types.Float),
'IntegerField': simple(types.Integer),
'BigIntegerField': simple(types.BigInteger),
'IPAddressField': lambda field: types.CHAR(length=15),
'NullBooleanField': simple(types.Boolean),
'OneToOneField': foreign_key,
'ForeignKey': foreign_key,
'PositiveIntegerField': simple(types.Integer),
'PositiveSmallIntegerField': simple(types.SmallInteger),
'SlugField': varchar,
'SmallIntegerField': simple(types.SmallInteger),
'TextField': simple(types.Text),
'TimeField': simple(types.Time),
}
# Update with dialect specific data types
DATA_TYPES['ArrayField'] = lambda field: postgres.array_type(DATA_TYPES, field)
# Update with user specified data types
DATA_TYPES.update(getattr(settings, 'ALDJEMY_DATA_TYPES', {}))
def get_django_models():
return django_apps.get_models()
from aldjemy.types import simple, foreign_key, varchar
from aldjemy import postgres
DATA_TYPES = {
'AutoField': simple(types.Integer),
'BigAutoField': simple(types.BigInteger),
'BooleanField': simple(types.Boolean),
'CharField': varchar,
'CommaSeparatedIntegerField': varchar,
'DateField': simple(types.Date),
'DateTimeField': simple(types.DateTime),
'DecimalField': lambda x: types.Numeric(scale=x.decimal_places,
precision=x.max_digits),
'DurationField': simple(types.Interval),
'FileField': varchar,
'FilePathField': varchar,
'FloatField': simple(types.Float),
'IntegerField': simple(types.Integer),
'BigIntegerField': simple(types.BigInteger),
'IPAddressField': lambda field: types.CHAR(length=15),
'NullBooleanField': simple(types.Boolean),
'OneToOneField': foreign_key,
'ForeignKey': foreign_key,
'PositiveIntegerField': simple(types.Integer),
'PositiveSmallIntegerField': simple(types.SmallInteger),
'SlugField': varchar,
'SmallIntegerField': simple(types.SmallInteger),
'TextField': simple(types.Text),
'TimeField': simple(types.Time),
}
from django.apps import apps as django_apps
except ImportError:
from django.db.models.loading import AppCache
django_apps = AppCache()
from aldjemy.types import simple, foreign_key, varchar
from aldjemy import postgres
DATA_TYPES = {
'AutoField': simple(types.Integer),
'BigAutoField': simple(types.BigInteger),
'BooleanField': simple(types.Boolean),
'CharField': varchar,
'CommaSeparatedIntegerField': varchar,
'DateField': simple(types.Date),
'DateTimeField': simple(types.DateTime),
'DecimalField': lambda x: types.Numeric(scale=x.decimal_places,
precision=x.max_digits),
'DurationField': simple(types.Interval),
'FileField': varchar,
'FilePathField': varchar,
'FloatField': simple(types.Float),
'IntegerField': simple(types.Integer),
'BigIntegerField': simple(types.BigInteger),
'IPAddressField': lambda field: types.CHAR(length=15),
'NullBooleanField': simple(types.Boolean),
'OneToOneField': foreign_key,
'ForeignKey': foreign_key,
'PositiveIntegerField': simple(types.Integer),
'PositiveSmallIntegerField': simple(types.SmallInteger),
'SlugField': varchar,
'BigAutoField': simple(types.BigInteger),
'BooleanField': simple(types.Boolean),
'CharField': varchar,
'CommaSeparatedIntegerField': varchar,
'DateField': simple(types.Date),
'DateTimeField': simple(types.DateTime),
'DecimalField': lambda x: types.Numeric(scale=x.decimal_places,
precision=x.max_digits),
'DurationField': simple(types.Interval),
'FileField': varchar,
'FilePathField': varchar,
'FloatField': simple(types.Float),
'IntegerField': simple(types.Integer),
'BigIntegerField': simple(types.BigInteger),
'IPAddressField': lambda field: types.CHAR(length=15),
'NullBooleanField': simple(types.Boolean),
'OneToOneField': foreign_key,
'ForeignKey': foreign_key,
'PositiveIntegerField': simple(types.Integer),
'PositiveSmallIntegerField': simple(types.SmallInteger),
'SlugField': varchar,
'SmallIntegerField': simple(types.SmallInteger),
'TextField': simple(types.Text),
'TimeField': simple(types.Time),
}
# Update with dialect specific data types
DATA_TYPES['ArrayField'] = lambda field: postgres.array_type(DATA_TYPES, field)
# Update with user specified data types
from sqlalchemy import types, Column, Table
import django
from django.conf import settings
try:
from django.apps import apps as django_apps
except ImportError:
from django.db.models.loading import AppCache
django_apps = AppCache()
from aldjemy.types import simple, foreign_key, varchar
from aldjemy import postgres
DATA_TYPES = {
'AutoField': simple(types.Integer),
'BigAutoField': simple(types.BigInteger),
'BooleanField': simple(types.Boolean),
'CharField': varchar,
'CommaSeparatedIntegerField': varchar,
'DateField': simple(types.Date),
'DateTimeField': simple(types.DateTime),
'DecimalField': lambda x: types.Numeric(scale=x.decimal_places,
precision=x.max_digits),
'DurationField': simple(types.Interval),
'FileField': varchar,
'FilePathField': varchar,
'FloatField': simple(types.Float),
'IntegerField': simple(types.Integer),
'BigIntegerField': simple(types.BigInteger),
'IPAddressField': lambda field: types.CHAR(length=15),
'NullBooleanField': simple(types.Boolean),