DatabaseLibrary乙個令人疑惑的問題

2021-09-18 06:30:13 字數 1630 閱讀 7006

在robotframework中使用 databaselibrary時,有個引數令我很疑惑,它就是 sanstran,這個引數在很多地方出現,它的解釋是

set optional input

`sanstran` to true to run command without an explicit transaction

commit or rollback.

我的理解是,當這個引數設定為true時,不用在顯式的呼叫commit和rollback。  但是其實現**如下,以

execute_sql_string為例:
def execute_sql_string(self, sqlstring, sanstran=false):

"""executes the sqlstring as sql commands and returns number of rows

affected. useful to pass arguments to your sql. set optional input

`sanstran` to true to run command without an explicit transaction

commit or rollback.

sql commands are expected to be delimited by a semi-colon (';').

for example:

| execute sql string | delete from person_employee_table; delete from person_table |

for example with an argument:

| execute sql string | select * from person where first_name = $ |

using optional `sanstran` to run command without an explicit transaction commit or rollback:

| execute sql string | delete from person_employee_table; delete from person_table | true |

"""cur = none

result = 0

try:

cur = self._dbconnection.cursor()

logger.info('executing : execute sql string | %s ' % sqlstring)

result = self.__execute_sql(cur, sqlstring)

if not sanstran:

self._dbconnection.commit()

finally:

if cur:

if not sanstran:

self._dbconnection.rollback()

return result

可以看到,只有當sanstran為false時,才會自動commit或者rollback。

是我理解錯了,還是文件寫的有問題呢????

乙個小疑惑

auto ply new playerchannel 看到這個我想到和new playerchannel 到底有啥區別 預設建構函式 只有當不提供任何建構函式,編譯器才會合成乙個預設建構函式,引數初始化取決於定義物件的位置 當提供乙個函式時就不會有預設建構函式 不管new playerchannel...

Metric Learning的乙個疑惑

我看的是liu yang的survey distance metric learning a comprehensive survey.裡面總結道,eric xing等把metric learning formulate成這樣乙個凸優化問題 begin min limits sum limits i...

乙個關於kylin的疑惑

自從研究了kylin這個系統之後,就一直有乙個疑惑,那就是kylin針對某一特定查詢條件建立的cube,只能在這個條件下查詢預計算的結果,如果條件一旦換了,cube就廢了。帶著這個疑問我在很多技術群裡和別人討論和爭辯,都沒有結果。看了很多網上分析的文章,都沒有關於這個疑問的詳細解答,於是今天自己試著...