MCPcopy Create free account
hub / github.com/aaPanel/BaoTa / query

Method query

class/wptoolkitModel/sqlite_easy.py:2098–2130  ·  view source on GitHub ↗

@name 查询 @author Zhj<2022-07-17> @param raw_sql sql语句 @param params 绑定参数[可选] @param take_first 是否只获取一行数据[可选 默认获取所有行] @param clear_conditions<?bool> 是否清空查询条件[可选 默认清空]

(self, raw_sql, params=(), take_first=False, clear_conditions=True)

Source from the content-addressed store, hash-verified

2096 return self
2097
2098 def query(self, raw_sql, params=(), take_first=False, clear_conditions=True):
2099 ''&#x27;
2100 @name 查询
2101 @author Zhj<2022-07-17>
2102 @param raw_sql<string> sql语句
2103 @param params<list|tuple> 绑定参数[可选]
2104 @param take_first<bool> 是否只获取一行数据[可选 默认获取所有行]
2105 @param clear_conditions<?bool> 是否清空查询条件[可选 默认清空]
2106 @return list|dict|None
2107 ''&#x27;
2108 if self.__DB is None:
2109 return None
2110
2111 # 记录语句执行开始时间
2112 s_time = time.time()
2113
2114 # 执行sql语句
2115 ret = self.__DB.client().query(raw_sql, _to_tuple(params), take_first)
2116
2117 # 写日志
2118 if self.__DB.is_debug():
2119 self.__DB.debug_log(self.__to_raw_sql(raw_sql, _to_tuple(params)), self.__DB.db_name(),
2120 time.time() - s_time)
2121
2122 # 自动提交事务
2123 # if self.__is_autocommit():
2124 # self.commit()
2125
2126 # 清空查询条件
2127 if clear_conditions:
2128 self.__clear()
2129
2130 return ret
2131
2132 def execute(self, raw_sql, params=(), get_rowid=False, clear_conditions=True):
2133 ''&#x27;

Callers 6

findMethod · 0.95
selectMethod · 0.95
existsMethod · 0.95
get_pkMethod · 0.95
get_columnsMethod · 0.95
explain_raw_sqlMethod · 0.95

Calls 9

__to_raw_sqlMethod · 0.95
__clearMethod · 0.95
timeMethod · 0.80
_to_tupleFunction · 0.70
queryMethod · 0.45
clientMethod · 0.45
is_debugMethod · 0.45
debug_logMethod · 0.45
db_nameMethod · 0.45

Tested by

no test coverage detected