GVKun编程网logo

在Python的sqlite3模块中,为什么cursor.rowcount()无法告诉我select语句返回的行数

15

此处将为大家介绍关于在Python的sqlite3模块中,为什么cursor.rowcount的详细内容,并且为您解答有关无法告诉我select语句返回的行数的相关问题,此外,我们还将为您介绍关于AS

此处将为大家介绍关于在Python的sqlite3模块中,为什么cursor.rowcount的详细内容,并且为您解答有关无法告诉我select语句返回的行数的相关问题,此外,我们还将为您介绍关于ASP中获得Select Count语句返回值的方法、cursor.rowcount在python3k的sqlite3中始终为-1、hibernate select语句返回的类型、MongoDB中cursor.count()和cursor.size()之间的区别的有用信息。

本文目录一览:

在Python的sqlite3模块中,为什么cursor.rowcount()无法告诉我select语句返回的行数

在Python的sqlite3模块中,为什么cursor.rowcount()无法告诉我select语句返回的行数

所以我已经阅读了文档,上面写着:

游标。行计数露

尽管sqlite3模块的Cursor类实现了此属性,但是数据库引擎自己对确定受影响的流''/选定的流’‘的支持是奇怪的。

这包括SELECT语句,因为在获取所有行之前,我们无法确定查询产生的行数。

怎么了,在执行SELECT之后,我无法立即使用它来确定返回的行数。确定执行了查询后,现在已经获取了所有行吗?

ASP中获得Select Count语句返回值的方法

ASP中获得Select Count语句返回值的方法

我们一般统计数据库记录时会用到Select Count(*)语句,当我们使用SQL Server的查询分析器时,直接输入Select Count(*) From 表名即会统计出该表中有几条记录,可是我们用ASP来实现时该怎么返回值呢?即如何输出统计出来的记录总数呢?请接着往下看。

其实我们只要给SQL语句的查询结果取个别名即可解决问题,然后用ASP语句输出这个别名即可,相关代码如下:

复制代码 代码如下:

Set rs=conn.Execute("Select Count(*) As ''Total'' From 表")
Response.Write rs("Total")

您可能感兴趣的文章:
  • ASP 写的自动生成SELECT 表单的函数

cursor.rowcount在python3k的sqlite3中始终为-1

cursor.rowcount在python3k的sqlite3中始终为-1

我试图让rowcount一个sqlite3
cursor在我Python3k程序,但我百思不得其解,因为rowcount始终是-1,尽管什么Python3文档说(其实是矛盾的,它应该是None)。即使在获取所有行之后,rowcount仍停留在-1。是sqlite3虫子吗?我已经检查了表中是否有行。

如果afetchone()返回的值与有所不同None,我可以解决这个问题,但是我认为这个问题可以讨论。

谢谢。

答案1

小编典典

从文档中:

根据Python DB API规范的要求,rowcount属性为“ -1,以防在游标上未执行executeXX()或接口无法确定最后一个操作的行数”。

这包括SELECT语句,因为在获取所有行之前,我们无法确定查询产生的行数。

这意味着 所有 SELECT语句 都不会包含rowcount。您观察到的行为已记录在案。

编辑: 文档没有说在您执行操作rowcount 后将 要更新的任何地方,fetchall()因此假设这样做是错误的。

hibernate select语句返回的类型

hibernate select语句返回的类型

Person类中包含有MyEvent这个类 

public class Person{
   private Long id;
   private String name;
   private MyEvent myEvent;
}

一、HQL from语句 

1、结果类型:List<Person>

from Person  或者 from Person as p
from Person as p where p.myEvent.title = :title
注意:hibernate3.2.3之前总是对的。 
   hibernate3.2.3之后如果myEvent是普通属性或关联的实体也是对的,如果myEvent是一个集合会出异常 
   因此hibernate推荐使用下面的方式:
select p from Person as p inner join p.myEvent as e where e.title = :title

2、结果类型 List<Person,Event>

from Person as p inner join p.myEvent as event where event.title = : title
注:查询出来是:是一个集合,集合元素是Person,myEvent组成的数组。 
   结果类型: List<Person,Event> 
from Person as p left outer join p.myEvent as event where event.title = : title

注意:查询出来是:是一个集合,集合元素是Person,myEvent组成的数组。 
           结果类型: List<Person,Event>

from Person as p right outer join p.myEvent as event where event.title = : title
from Person as p full join p.myEvent as event where event.title = : title

第二:HQL select语句 

1、结果类型:  List<String> 

select p.name from Person as p

2、结果类型:List<Object[String,Person]>

select p.name,p from Person as p

3、结果类型:List<String,String>

select new List(p.name,p.address) from Person as p

4、结果类型:List<ClassTest>

select new ClassTest(p.name,p.address) from Person as p

   注意:前提ClassTest 类有两个参数的构造器。 

5、结果类型:List<map<String,String>>

select new map(p.name as personName) from Person as p

 

MongoDB中cursor.count()和cursor.size()之间的区别

MongoDB中cursor.count()和cursor.size()之间的区别

MongoDB的cursor.count()cursor.size()方法之间有什么区别DBCursor

今天关于在Python的sqlite3模块中,为什么cursor.rowcount无法告诉我select语句返回的行数的讲解已经结束,谢谢您的阅读,如果想了解更多关于ASP中获得Select Count语句返回值的方法、cursor.rowcount在python3k的sqlite3中始终为-1、hibernate select语句返回的类型、MongoDB中cursor.count()和cursor.size()之间的区别的相关知识,请在本站搜索。

本文标签:

上一篇SQL替换字符串中的多个不同字符

下一篇如何在SQL Server 2012中的SQLCLR程序集中使用TimeZoneInfo