想了解cursor.rowcount在python3k的sqlite3中始终为-1的新动态吗?本文将为您提供详细的信息,此外,我们还将为您介绍关于asp.net-mvc–为什么HttpContext.
想了解cursor.rowcount在python3k的sqlite3中始终为-1的新动态吗?本文将为您提供详细的信息,此外,我们还将为您介绍关于asp.net-mvc – 为什么HttpContext.Current在asp.net mvc中的用户定义类中始终为null?、c# – MongoCursor.Count vs … IAsyncCursor.Count?、CentOS7.5 安装 Python3.7 报错:configure: error: no acceptable C compiler found in $PATH --Python3、oracle中的sql%rowcount,sql%found、sql%notfound、sql%rowcount和sql%isopen的新知识。
本文目录一览:- cursor.rowcount在python3k的sqlite3中始终为-1
- asp.net-mvc – 为什么HttpContext.Current在asp.net mvc中的用户定义类中始终为null?
- c# – MongoCursor.Count vs … IAsyncCursor.Count?
- CentOS7.5 安装 Python3.7 报错:configure: error: no acceptable C compiler found in $PATH --Python3
- oracle中的sql%rowcount,sql%found、sql%notfound、sql%rowcount和sql%isopen
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()
因此假设这样做是错误的。
asp.net-mvc – 为什么HttpContext.Current在asp.net mvc中的用户定义类中始终为null?
public string ProcessLongRunningAction(IEnumerable<HttpPostedFileBase> files,string id) { int currentIndex = 0; foreach (HttpPostedFileBase file in files) { currentIndex++; lock(syncRoot) { string path=HttpContext.Current.Server.MapPath("~//Content//images //"+file.FileName);//Excecption is created here........ file.SaveAs(path); } Thread.Sleep(300); } return id; }
从控制器调用此方法,使用文件列表保存在images目录中.每当执行HttpContext.Current.Server.MapPath(“〜// Content // images //”file.FileName)时,抛出NullReferenceException,并且HttpContext.Current始终为null.当我使用session时会发生同样的事情.我不知道代码有什么问题.
解决方法
但是,当您未在原始请求线程中运行时,HttpContext.Current将返回null.这是explained here.
如果在创建的每个线程上手动设置上下文,则可以使用它.这在SO中的类似问题上进行了讨论,如here和here.
但是,考虑到你的问题中的代码,如果你只是为该方法中的路径添加一个参数会更好,正如Johann Blais建议的那样.然后,您将解析原始请求线程中的路径并将其传递给该方法,然后该方法可以在分离的线程上运行.这样你的方法就不依赖于HttpContext.Current.
c# – MongoCursor.Count vs … IAsyncCursor.Count?
我们的想法是通过分页(跳过和限制)查询文档,只有一个数据库命中,获取文档,返回文档的计数和没有LIMIT的所有文档的计数
使用MongoDB C#传统驱动程序,我曾经这样做过:
MongoCursor<SaleOrderModel> result = collection.FindAs<SaleOrderModel>(query); result.setSkip(20); result.setLimit(10); var saleOrders = result.ToList<SaleOrderModel>(); // 'limited' documents var size = result.Size(); // Count of 'limited' documents var count = result.Count(); // Count of all documents found (even if they are not returned)
解决方法
Find
返回的
IFindFluent
fluent查询界面使用2.0驱动程序执行此操作:
// Create the IFindFluent<SaleOrderModel> query. var collection = db.GetCollection<SaleOrderModel>("saleOrders"); var filter = Builders<SaleOrderModel>.Filter.Eq(so => so.vendorId,5); var query = collection.Find(filter); // Get the count of all docs matching the query. var count = await query.CountAsync(); // Execute the query with skip and limit. var saleOrders = await query.Skip(20).Limit(10).ToListAsync(); var size = saleOrders.Count();
CentOS7.5 安装 Python3.7 报错:configure: error: no acceptable C compiler found in $PATH --Python3
1、问题解析
报错信息中有这样一条:configure: error: no acceptable C compiler found in $PATH 即:配置错误,在 $path 中找不到可接受的 C 编译器
2、解决方式
安装 C 编译器 gcc (GNU 编译器套件):
yum -y install gcc
3、扩展
gcc 即:GNU 编译器套件 (GNU Compiler Collection) 包括 C、C++、Objective-C、Fortran、Java、Ada 和 Go 语言的前端,也包括了这些语言的库(如 libstdc++、libgcj 等等)。GCC 的初衷是为 GNU 操作系统专门编写的一款编译器.
oracle中的sql%rowcount,sql%found、sql%notfound、sql%rowcount和sql%isopen
Oracle 存储过程 删除表记录时删除不存在的记录也是显示删除成功
create or replace procedure delDept(p_deptno in dept.deptno%type) is begin delete from dept where deptno=p_deptno; dbms_output.put_line('部门删除成功...'); exception when others then dbms_output.put_line('部门删除失败...'); end; 删除不存在的数据并不会促发Oracle的异常 对于delete from dept where deptno=p_deptno; 判断是否有数据被删除可以用sql%rowcount,sql%notfound 来判断 if sql%rowcount = 0 then dbms_output.put_line('部门删除失败...'); end if; 或者 if sql%notfound then dbms_output.put_line('部门删除失败...'); end if; create or replace procedure delDept(p_deptno in dept.deptno%type) is EmpCount NUMBER; --影响的记录数 begin delete from dept where deptno=p_deptno; EmpCount := sql%rOWCOUNT; if(EmpCount <>0) then dbms_output.put_line('部门删除成功...'); exception when others then dbms_output.put_line('部门删除失败...'); end;