Returns the actual sql query for the CreateLibraryCommand class.
545810
def visit_create_library_command(element, compiler, **kw):
    
    query = """
        CREATE {or_replace} LIBRARY {name}
        LANGUAGE pythonplu
        FROM :location
        WITH CREDENTIALS AS :credentials
        {region}
    """
    bindparams = [
        sa.bindparam(
            'location',
            value=element.location,
            type_=sa.String,
        ),
        sa.bindparam(
            'credentials',
            value=element.credentials,
            type_=sa.String,
        ),
    ]

    if element.region is not None:
        bindparams.append(sa.bindparam(
            'region',
            value=element.region,
            type_=sa.String,
        ))

    quoted_lib_name = compiler.preparer.quote_identifier(element.library_name)
    query = query.format(name=quoted_lib_name,
                         or_replace='OR REPLACE' if element.replace else '',
                         region='REGION :region' if element.region else '')
    return compiler.process(sa.text(query).bindparams(*bindparams), **kw)
338892
public static Sql getSql(String query, Map<String, Object> parameters) {
		SqlBuilder builder = new SqlBuilder();
		String sql = builder.replaceVariables(query, parameters);
		return new Sql(sql, parameters);
	}
436554
public static @NotNull SqlQuery query(@NotNull @SQL String sql, Object... args) {
        return new SqlQuery(sql, asList(args));
    }
1110151
private CommandOutput<?, ?> executeSql(List<Command> cmds) {
    String query = null;
    int fetchSize = 0;

    for (Command cmd : cmds) {
      if (cmd instanceof JdbcCommand) {
        JdbcCommandType type = (JdbcCommandType) cmd.getCommandType();
        switch (type) {
          case QUERY:
            query = cmd.getParams().get(0);
            break;
          case FETCHSIZE:
            fetchSize = Integer.parseInt(cmd.getParams().get(0));
            break;
          default:
            this.log.error("Command " + type.toString() + " not recognized");
            break;
        }
      }
    }

    this.log.info("Executing query:" + query);
    ResultSet resultSet = null;
    try {
      this.jdbcSource = createJdbcSource();
      if (this.dataConnection == null) {
        this.dataConnection = this.jdbcSource.getConnection();
      }
      Statement statement = this.dataConnection.createStatement();

      if (fetchSize != 0 && this.getExpectedRecordCount() > 2000) {
        statement.setFetchSize(fetchSize);
      }
      final boolean status = statement.execute(query);
      if (status == false) {
        this.log.error("Failed to execute sql:" + query);
      }
      resultSet = statement.getResultSet();
    } catch (Exception e) {
      this.log.error("Failed to execute sql:" + query + " ;error-" + e.getMessage(), e);
    }

    CommandOutput<JdbcCommand, ResultSet> output = new JdbcCommandOutput();
    output.put((JdbcCommand) cmds.get(0), resultSet);
    return output;
  }
26423
public static SqlBuilder sql(final String queryStr) {
    SqlBuilder sqlQuery = new SqlBuilder();
    sqlQuery.statement = queryStr;
    return sqlQuery;
  }
370783
def rawsql(query, ec=None):
    
    if isinstance(query, Result):
        query = query.get_query()

    ec = ec or __default_engine__
    if isinstance(ec, (str, unicode)):
        engine = engine_manager[ec]
        dialect = engine.engine.dialect
    else:
        dialect = ec.dialect
    if isinstance(query, (str, unicode)):
        return query
    # comp = query.compile(dialect=dialect)

    compiler = query._compiler(dialect)
    class LiteralCompiler(compiler.__class__):
        def visit_bindparam(
                self, bindparam, within_columns_clause=False,
                literal_binds=False, **kwargs
        ):
            return super(LiteralCompiler, self).render_literal_bindparam(
                    bindparam, within_columns_clause=within_columns_clause,
                    literal_binds=literal_binds, **kwargs
            )
        def render_literal_value(self, value, type_):
            """Render the value of a bind parameter as a quoted literal.

            This is used for statement sections that do not accept bind paramters
            on the target driver/database.

            This should be implemented by subclasses using the quoting services
            of the DBAPI.

            """
            return repr_value(value)

    compiler = LiteralCompiler(dialect, query)
    return str(compiler.process(query)).replace('\n', '')
752335
private String buildQuery() {
        fetchKeys();

        List<String> columns = getSelectColumns();
        String selectColumnList = columns.size() == 0 ? "*" : makeColumnList(columns);
        String partitionKeyList = makeColumnList(partitionKeys);

        return String.format("SELECT %s FROM %s.%s WHERE token(%s)>? AND token(%s)<=?" + getAdditionalWhereClauses(),
                selectColumnList, quote(keyspace), quote(cfName), partitionKeyList, partitionKeyList);
    }
1231224
public function createQuery()
    {
        $query = new Query($this->objectType);
        if ($this->defaultOrderings) {
            $query->setOrderings($this->defaultOrderings);
        }
        return $query;
    }
365451
function outputQuery(compiled, isParameter) {
    var sql = compiled.sql || '';
    if (sql) {
      if (compiled.method === 'select' && (isParameter || compiled.as)) {
        sql = '(' + sql + ')';
        if (compiled.as) {
          return this.alias(sql, this.wrap(compiled.as));
        }
      }
    }
    return sql;
  }
1068330
def select(self,sql):
    
    if not self.curs:
      raise LIGOLwDBError, "Database connection not initalized"
    if len(self.table) != 0:
      raise LIGOLwDBError, 'attempt to fill non-empty table from database'
    ligolw = ''
    self.table = {}
    sqltypes = {
      -2 : 'ilwd:char_u',
      1 : 'lstring',
      3 : 'real_8',
      4  : 'int_4s',
      5 : 'int_2s',
      7 : 'real_4',
      8 : 'real_8',
      12 : 'lstring',
      93 : 'lstring', 
      }
    try:
      tab = re.compile(r'[Ff][Rr][Oo][Mm]\s+([A-Za-z0-0_]+)([,\s]+|$)').search(sql).group(1)
    except AttributeError:
      raise LIGOLwDBError, 'could not find table name in query ' + str(sql)
    self.table[tab] = {
      'pos' : 0,
      'column' : {},
      'stream' : (), 
      'query' : sql
      }
    try:
      self.curs.execute(sql)
    except DB2.Error, e:
      raise LIGOLwDBError, e[2]
    desc = self.curs.description
    for col,typ,disp,intsz,prec,sca,nul in desc:
      try:
        self.table[tab]['column'][col] = sqltypes[typ]
      except KeyError:
        raise LIGOLwDBError, 'unknown type returned by database ' + str(typ)
      self.table[tab].setdefault('orderedcol',[]).append(col)

    try:
      self.table[tab]['stream'] = self.curs.fetchall()
    except DB2.Error, e:
      raise LIGOLwDBError, e[2]

    return len(self.table[tab]['stream'])
43267
@SafeVarargs
  public static Query query(DB db, String sql, Object... args) {
    return new Query(db, sql, args);
  }
694728
private Query createQuery(PriorityQueue<Object[]> q)
   {
      BooleanQuery query = new BooleanQuery();
      Object cur;
      int qterms = 0;
      float bestScore = 0;

      while (((cur = q.pop()) != null))
      {
         Object[] ar = (Object[])cur;
         TermQuery tq = new JcrTermQuery(new Term((String)ar[1], (String)ar[0]));

         if (boost)
         {
            if (qterms == 0)
            {
               bestScore = ((Float)ar[2]).floatValue();
            }
            float myScore = ((Float)ar[2]).floatValue();

            tq.setBoost(myScore / bestScore);
         }

         try
         {
            query.add(tq, BooleanClause.Occur.SHOULD);
         }
         catch (BooleanQuery.TooManyClauses ignore)
         {
            break;
         }

         qterms++;
         if (maxQueryTerms > 0 && qterms >= maxQueryTerms)
         {
            break;
         }
      }

      return query;
   }
1026886
@Override
    @SuppressWarnings("rawtypes")
    public Query createNativeQuery(String sqlString, Class resultClass)
    {
        return ivEm.createNativeQuery(sqlString, resultClass);
    }
1319662
@Override
    public final Query createNativeQuery(String sqlString, Class resultClass)
    {
        checkClosed();
        checkTransactionNeeded();

        return getPersistenceDelegator().createNativeQuery(sqlString, resultClass);
    }
341642
public function createQuery()
    {
        $query = $this->persistenceManager->createQueryForType($this->entityClassName);
        if ($this->defaultOrderings !== []) {
            $query->setOrderings($this->defaultOrderings);
        }
        return $query;
    }
48014
private function getSQL()
    {
        $sql = $this->getTypeSQL()
                . $this->getWhereSQL()
                . $this->getOrderSQL()
                . $this->getLimitSQL()
                . $this->getOffsetSQL();
        return $sql;
    }
1058127
private Query getQueryBySqlCount(QueryBySQL aQuery)
    {
        String countSql = aQuery.getSql();

        int fromPos = countSql.toUpperCase().indexOf(" FROM ");
        if(fromPos >= 0)
        {
            countSql = "select count(*)" + countSql.substring(fromPos);
        }

        int orderPos = countSql.toUpperCase().indexOf(" ORDER BY ");
        if(orderPos >= 0)
        {
            countSql = countSql.substring(0, orderPos);
        }

        return new QueryBySQL(aQuery.getSearchClass(), countSql);
    }