删除后,Python sqlalchemy返回值

时间:2019-07-19 07:19:59

标签: python sqlalchemy

在sqlalchemy中删除后如何返回值。

这是我要实现的查询:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="dele">
  <img src="https://cdn3.volusion.com/yuqpe.xcnnr/v/vspfiles/photos/25-cent-E-liquid-Sample-2.jpg?1475251487">
  <div class="alert">
    <div class="note">Are you sure?</div>
    <ul class="yesorno">
      <li class="yes"><a href="unlink.php?name='img1'">Yes</a></li>
      <li class="no">No</li>
    </ul>
  </div>
</div>
<div class="dele">
  <img src="https://cdn3.volusion.com/yuqpe.xcnnr/v/vspfiles/photos/25-cent-E-liquid-Sample-2.jpg?1475251487">
  <div class="alert">
    <div class="note">Are you sure?</div>
    <ul class="yesorno">
      <li class="yes"><a href="unlink.php?name='img2'">Yes</a></li>
      <li class="no">No</li>
    </ul>
  </div>
</div>
<div class="dele">
  <img src="https://cdn3.volusion.com/yuqpe.xcnnr/v/vspfiles/photos/25-cent-E-liquid-Sample-2.jpg?1475251487">
  <div class="alert">
    <div class="note">Are you sure?</div>
    <ul class="yesorno">
      <li class="yes"><a href="unlink.php?name='img3'">Yes</a></li>
      <li class="no">No</li>
    </ul>
  </div>
</div>
<div class="dele">
  <img src="https://cdn3.volusion.com/yuqpe.xcnnr/v/vspfiles/photos/25-cent-E-liquid-Sample-2.jpg?1475251487">
  <div class="alert">
    <div class="note">Are you sure?</div>
    <ul class="yesorno">
      <li class="yes"><a href="unlink.php?name='img4'">Yes</a></li>
      <li class="no">No</li>
    </ul>
  </div>
</div>

但这是我目前拥有的:

DELETE FROM sometable WHERE id = 1 returning id

删除后我需要从该表中返回值,有人可以帮助我吗?

1 个答案:

答案 0 :(得分:-2)

只需对表对象调用drop()即可。从文档中:

使用给定的Connectable进行连接,为此表发出DROP语句。

您的情况应该是:

.drop() 如果您遇到类似这样的异常:

sqlalchemy.exc.UnboundExecutionError:表对象“未绑定到引擎或连接。如果没有要执行的数据库,执行将无法进行 您需要通过引擎:

.drop(引擎)