Compile a truncate statement into SQL

        :param query: A QueryBuilder instance
        :type query: QueryBuilder

        :return: The compiled truncate statement
        :rtype: str
545953
def compile_truncate(self, query):
        
        sql = {
            "DELETE FROM sqlite_sequence WHERE name = %s"
            % self.get_marker(): [query.from__]
        }

        sql["DELETE FROM %s" % self.wrap_table(query.from__)] = []

        return sql
753889
public function compileSelect(Builder $query)
    {
        if (is_null($query->columns)) {
            $query->columns = ['*'];
        }

        $components = $this->compileComponents($query);

        // If an offset is present on the query, we will need to wrap the query in
        // a big "ANSI" offset syntax block. This is very nasty compared to the
        // other database systems but is necessary for implementing features.
        if ($this->isPaginationable($query, $components)) {
            return $this->compileAnsiOffset($query, $components);
        }

        return trim($this->concatenate($components));
    }
120952
def result(self, *args, **kwargs):
        
        prettify = kwargs.get('pretty', False)

        sql = 'DELETE %s %s' % (self._type, self._class)
        
        if prettify:
            sql += '\n'
        else:
            sql += ' '

        if self.where_criteria.size() > 0:
            sql +=  'WHERE '
            sql +=  self.where_criteria.result()
            if prettify:
                sql += '\n'
            else:
                sql += ' '
        
        return sql
1001433
def parse_query(self, query):
        """"""
        tree = pypeg2.parse(query, Main, whitespace="")
        return tree.accept(self.converter)
108157
public function compileSelect(Builder $query)
    {
        $original = $query->columns;

        if (is_null($query->columns)) {
            $query->columns = ['*'];
        }

        $sql = trim($this->concatenate($this->compileComponents($query)));

        $query->columns = $original;

        return $sql;
    }
116860
def compile(self):
        """"""
        sql = ''
        sql += 'DELETE FROM ' + self.dialect.quote_table(self._table)
        if self._where:
            sql += ' WHERE ' + self.compile_condition(self._where)
        if self._order_by:
            sql += ' ' + self.compile_order_by(self._order_by)

        if self._limit:
            sql += ' LIMIT ' + self._limit
        return sql
147821
def executeSQL(self, sql, args=()):
        
        sql = self._execSQL(sql, args)
        result = self.cursor.lastRowID()
        if self.executedThisTransaction is not None:
            self.executedThisTransaction.append((result, sql, args))
        return result
368992
public static long longForQuery(SQLiteDatabase db, String query, String[] selectionArgs) {
        SQLiteStatement prog = db.compileStatement(query);
        try {
            return longForQuery(prog, selectionArgs);
        } finally {
            prog.close();
        }
    }
642081
static void truncate(CallInfo callInfo, Table table) {
    final DB db = table.getDB();   
    db.access(callInfo, () -> {
      String sql = "TRUNCATE TABLE " + table.getName();
      table.setDirtyStatus(true);
      db.logSetup(callInfo, sql);
      try (WrappedStatement ws = db.compile(sql)) {
        ws.getStatement().execute();
      }
      return 0;
    });

  }
628710
def mogrify(self, query, args=None):
        
        conn = self._get_db()
        if PY2:  # Use bytes on Python 2 always
            query = self._ensure_bytes(query, encoding=conn.encoding)

        if args is not None:
            query = query % self._escape_args(args, conn)

        return query
694516
def encoder(self, query: Dict[str, Any]):
        
        if self.debug is True:
            queryb = json.dumps(
                query,
                ensure_ascii=False).encode("utf-8")
        else:
            queryb = msgpack.packb(query)

        if self.compreser:
            queryb = self.compreser.compress(queryb)

        return queryb + self.SEPARATOR
1189373
def execute_query_return_result_proxy(query):
    
    context = query._compile_context()
    context.statement.use_labels = False
    if query._autoflush and not query._populate_existing:
        query.session._autoflush()

    conn = query._get_bind_args(
        context,
        query._connection_from_session,
        close_with_result=True)

    return conn.execute(context.statement, query._params)
731763
def wrap(query, container, namespace):
        
        if is_op(query, QueryOp) or query == None:
            return query

        query = wrap(query)
        table = container.get_table(query['from'])
        schema = table.schema
        output = QueryOp(
            frum=table,
            format=query.format,
            limit=mo_math.min(MAX_LIMIT, coalesce(query.limit, DEFAULT_LIMIT))
        )

        if query.select or isinstance(query.select, (Mapping, list)):
            output.select = _normalize_selects(query.select, query.frum, schema=schema)
        else:
            if query.edges or query.groupby:
                output.select = DEFAULT_SELECT
            else:
                output.select = _normalize_selects(".", query.frum)

        if query.groupby and query.edges:
            Log.error("You can not use both the `groupby` and `edges` clauses in the same query!")
        elif query.edges:
            output.edges = _normalize_edges(query.edges, limit=output.limit, schema=schema)
            output.groupby = Null
        elif query.groupby:
            output.edges = Null
            output.groupby = _normalize_groupby(query.groupby, limit=output.limit, schema=schema)
        else:
            output.edges = Null
            output.groupby = Null

        output.where = _normalize_where(query.where, schema=schema)
        output.window = [_normalize_window(w) for w in listwrap(query.window)]
        output.having = None
        output.sort = _normalize_sort(query.sort)
        if not mo_math.is_integer(output.limit) or output.limit < 0:
            Log.error("Expecting limit >= 0")

        output.isLean = query.isLean

        return output
199697
def tokenize_query(query: str) -> Dict[str, Iterable]:
    
    expressions = split_query(query)
    name_operation_tuples = [parse_expression(expression) for expression in expressions]
    operation_by_name = defaultdict(list)
    for name, operation in name_operation_tuples:
        operation_by_name[name].append(operation)
    return operation_by_name
266354
def serialize_query(func):
        
        @functools.wraps(func)
        def wrapper(self, query, *args, **kwargs):
            if hasattr(query, 'serialize'):
                query = query.serialize()

            assert isinstance(query, basestring), 'Expected query to be string'
            if self.debug:
                print('SQL:', query)

            return func(self, query, *args, **kwargs)
        return wrapper
662642
public long queryForLong(DatabaseConnection databaseConnection, String query, String[] arguments)
			throws SQLException {
		logger.debug("executing raw query for long: {}", query);
		if (arguments.length > 0) {
			// need to do the (Object) cast to force args to be a single object
			logger.trace("query arguments: {}", (Object) arguments);
		}
		CompiledStatement compiledStatement = null;
		DatabaseResults results = null;
		try {
			compiledStatement = databaseConnection.compileStatement(query, StatementType.SELECT, noFieldTypes,
					DatabaseConnection.DEFAULT_RESULT_FLAGS, false);
			assignStatementArguments(compiledStatement, arguments);
			results = compiledStatement.runQuery(null);
			if (results.first()) {
				return results.getLong(0);
			} else {
				throw new SQLException("No result found in queryForLong: " + query);
			}
		} finally {
			IOUtils.closeThrowSqlException(results, "results");
			IOUtils.closeThrowSqlException(compiledStatement, "compiled statement");
		}
	}
72631
def query(self, sql):
        '''
        
        '''
        try:
            self.connect()
            with self.con.cursor() as cursor:
                cursor.execute(sql)
                self.con.commit()
                res = cursor.fetchall()
                return res
        except Exception as e:
            print(e)
            return -1
        finally:
            self.close()