Finds the name of the SQLAlchemy dialect in use.

    Args:
        mixed: an SQLAlchemy :class:`SQLCompiler`, :class:`Engine`, or
            :class:`Dialect` object

    Returns: the SQLAlchemy dialect name being used
779248
def get_dialect_name(mixed: Union[SQLCompiler, Engine, Dialect]) -> str:
    
    dialect = get_dialect(mixed)
    # noinspection PyUnresolvedReferences
    return dialect.name
51437
def DualDBFlow(cls):
  """"""

  if issubclass(cls, flow.GRRFlow):
    raise ValueError("Mixin class shouldn't inherit from GRRFlow.")

  if cls.__name__[-5:] != "Mixin":
    raise ValueError("Flow mixin should have a name that ends in 'Mixin'.")

  flow_name = cls.__name__[:-5]
  aff4_cls = type(flow_name, (cls, flow.GRRFlow), {})
  aff4_cls.__doc__ = cls.__doc__
  setattr(aff4_flows, flow_name, aff4_cls)

  reldb_cls = type(flow_name, (cls, FlowBase), {})
  reldb_cls.__doc__ = cls.__doc__
  setattr(sys.modules[cls.__module__], flow_name, reldb_cls)

  return cls
253631
def get_dependency_type(_type):
        
        if _type == DependencyTypes.AFTER:
            return 'after'
        elif _type == DependencyTypes.AFTER_ANY:
            return 'afterany'
        elif _type == DependencyTypes.AFTER_CORR:
            return 'aftercorr'
        elif _type == DependencyTypes.AFTER_NOT_OK:
            return 'afternotok'
        elif _type == DependencyTypes.AFTER_OK:
            return 'afterok'
        else:
            return None
1239129
def get_name(value) -> str:
    
    if value.__module__ == '__builtin__':
        return value.__name__
    else:
        return '.'.join((value.__module__, value.__name__))
1039476
def getTypesModuleName(self):
        
        if self.types_module_name is not None:
            return self.types_module_name

        name = GetModuleBaseNameFromWSDL(self._wsdl)
        if not name:
            raise WsdlGeneratorError, 'could not determine a service name'
        
        if self.types_module_suffix is None:
            return name

        return '%s%s' %(name, self.types_module_suffix)
114054
def dbType(self, typ):
        
        return self.TypeMap.get(typ, self.TypeMap.get('Default'))
235335
def makeHandler(self, dialect):
        """"""
        if dialect not in self.dialects:
            m = "The dialect specified, '{}', wasn't whitelisted in change_hook".format(dialect)
            log.msg(m)
            log.msg(
                "Note: if dialect is 'base' then it's possible your URL is malformed and we didn't regex it properly")
            raise ValueError(m)

        if dialect not in self._dialect_handlers:
            if dialect not in self._plugins:
                m = "The dialect specified, '{}', is not registered as a buildbot.webhook plugin".format(dialect)
                log.msg(m)
                raise ValueError(m)
            options = self.dialects[dialect]
            if isinstance(options, dict) and 'custom_class' in options:
                klass = options['custom_class']
            else:
                klass = self._plugins.get(dialect)
            self._dialect_handlers[dialect] = klass(self.master, self.dialects[dialect])

        return self._dialect_handlers[dialect]
59099
def dialect_class(self, adapter):
        """"""
        if self.dialects.get(adapter):
            return self.dialects[adapter]
        try:
            class_prefix = getattr(
                __import__('db.' + adapter, globals(), locals(),
                           ['__class_prefix__']), '__class_prefix__')
            driver = self._import_class('db.' + adapter + '.dialect.' +
                                        class_prefix + 'Dialect')
        except ImportError:
            raise DBError("Must install adapter `%s` or doesn't support" %
                          (adapter))

        self.dialects[adapter] = driver
        return driver
145178
public static String getSqlTypeAsString(int jdbcType)
    {
        String statusName = "*can't find String representation for sql type '" + jdbcType + "'*";
        try
        {
            Field[] fields = Types.class.getDeclaredFields();
            for (int i = 0; i < fields.length; i++)
            {
                if (fields[i].getInt(null) == jdbcType)
                {
                    statusName = fields[i].getName();
                    break;
                }
            }
        }
        catch (Exception ignore)
        {
            // ignore it
        }
        return statusName;
    }
635932
def db(self, connection_string=None):
        """"""

        connection_string = connection_string or self.settings["db"]

        if not hasattr(self, "_db_conns"):
            self._db_conns = {}
        if not connection_string in self._db_conns:
            self._db_conns[connection_string] = oz.sqlalchemy.session(connection_string=connection_string)

        return self._db_conns[connection_string]
276715
def type_name(self):
    

    res = self.type.__name__
    if self.type.__module__ not in ('__builtin__', 'builtins'):
      res = self.type.__module__ + '.' + res
    return res
1120745
def _parse_db_lib(cls, library):
        
        database_name = library.split('.', 2)
        if len(database_name) == 2:
            library = database_name[1]
            if database_name[0].startswith(cls.DB_PREFIX):
                database_name = database_name[0]
            else:
                database_name = cls.DB_PREFIX + '_' + database_name[0]
        else:
            database_name = cls.DB_PREFIX
        return database_name, library
313272
def get_name(cls):
        
        if not hasattr(cls.Meta, 'name'):
            class_name = getattr(cls.get_model(), '__name__', None)
            setattr(
                cls.Meta,
                'name',
                inflection.underscore(class_name) if class_name else None
            )

        return cls.Meta.name
126680
def mssql_get_pk_index_name(engine: Engine,
                            tablename: str,
                            schemaname: str = MSSQL_DEFAULT_SCHEMA) -> str:
    
    # http://docs.sqlalchemy.org/en/latest/core/connections.html#sqlalchemy.engine.Connection.execute  # noqa
    # http://docs.sqlalchemy.org/en/latest/core/sqlelement.html#sqlalchemy.sql.expression.text  # noqa
    # http://docs.sqlalchemy.org/en/latest/core/sqlelement.html#sqlalchemy.sql.expression.TextClause.bindparams  # noqa
    # http://docs.sqlalchemy.org/en/latest/core/connections.html#sqlalchemy.engine.ResultProxy  # noqa
    query = text("""
SELECT
    kc.name AS index_name
FROM
    sys.key_constraints AS kc
    INNER JOIN sys.tables AS ta ON ta.object_id = kc.parent_object_id
    INNER JOIN sys.schemas AS s ON ta.schema_id = s.schema_id
WHERE
    kc.[type] = 'PK'
    AND ta.name = :tablename
    AND s.name = :schemaname
    """).bindparams(
        tablename=tablename,
        schemaname=schemaname,
    )
    with contextlib.closing(
            engine.execute(query)) as result:  # type: ResultProxy  # noqa
        row = result.fetchone()
        return row[0] if row else ''
1140872
def _guess_name_of(self, expr):
        
        if isinstance(expr, ast.Var):
            return expr.value

        if isinstance(expr, ast.Resolve):
            # We know the RHS of resolve is a Literal because that's what
            # Parser.dot_rhs does.
            return expr.rhs.value

        if isinstance(expr, ast.Select) and isinstance(expr.rhs, ast.Literal):
            name = self._guess_name_of(expr.lhs)
            if name is not None:
                return "%s_%s" % (name, expr.rhs.value)

        if isinstance(expr, ast.Apply) and isinstance(expr.func, ast.Var):
            return expr.func.value
977428
def fail_unknown_dialect(compiler: "SQLCompiler", task: str) -> None:
    
    raise NotImplementedError(
        "Don't know how to {task} on dialect {dialect!r}. "
        "(Check also: if you printed the SQL before it was bound to an "
        "engine, you will be trying to use a dialect like StrSQLCompiler, "
        "which could be a reason for failure.)".format(
            task=task,
            dialect=compiler.dialect
        )
    )
683137
public static String resolveDataSourceTypeFromDialect(String dialect)
    {
        if (StringUtils.contains(dialect, "Oracle"))
        {
            return "Oracle";
        }
        else if (StringUtils.contains(dialect, "MySQL"))
        {
            return "MySQL";
        }
        else if (StringUtils.contains(dialect, "DB2390Dialect"))
        {
            return "DB2/390";
        }
        else if (StringUtils.contains(dialect, "DB2400Dialect"))
        {
            return "DB2/400";
        }
        else if (StringUtils.contains(dialect, "DB2"))
        {
            return "DB2";
        }
        else if (StringUtils.contains(dialect, "Ingres"))
        {
            return "Ingres";
        }
        else if (StringUtils.contains(dialect, "Derby"))
        {
            return "Derby";
        }
        else if (StringUtils.contains(dialect, "Pointbase"))
        {
            return "Pointbase";
        }
        else if (StringUtils.contains(dialect, "Postgres"))
        {
            return "Postgres";
        }
        else if (StringUtils.contains(dialect, "SQLServer"))
        {
            return "SQLServer";
        }
        else if (StringUtils.contains(dialect, "Sybase"))
        {
            return "Sybase";
        }
        else if (StringUtils.contains(dialect, "HSQLDialect"))
        {
            return "HyperSQL";
        }
        else if (StringUtils.contains(dialect, "H2Dialect"))
        {
            return "H2";
        }
        
        return dialect;

    }