我有一个ColdFusion页面,里面有一个样式化的HTML表格.我希望能够做的是设置一个功能,允许我们的客户将表保存为图像文件,以便在幻灯片中使用.我已经阅读了cfcontent的一些文档,但是我开始觉得我需要第三方库.我希望有人可以对此有所了解.
假设我有一个文件列表
files = ['s1.txt', 'ai1.txt', 's2.txt', 'ai3.txt']
Run Code Online (Sandbox Code Playgroud)
我需要根据它们的数量将它们分类到子列表中
files = [['s1.txt', 'ai1.txt'], ['s2.txt'], ['ai3.txt']]
Run Code Online (Sandbox Code Playgroud)
我可以写一堆循环,但我想知道是否有更好的方法来做到这一点?
我有一个检索大量数据的查询.
<cfsetting requesttimeout="9999999" >
<cfquery name="randomething" datasource="ds" timeout="9999999" >
SELECT
col1,
col2
FROM
table
</cfquery>
<cfdump var="#randomething.recordCount#" /> <!---should be about 5 million rows --->
Run Code Online (Sandbox Code Playgroud)
我可以使用python的cx_Oracle成功检索数据,并sys.getsizeof在python列表上使用返回22621060,所以大约21兆字节.
ColdFusion不会在页面上返回错误,我在任何日志中都找不到任何内容.为什么cfdump不显示行数?
附加信息
这样做的原因是因为我有大约8000个较小的查询来运行randomthing查询.换句话说,当我对数据库运行这8000个查询时,该过程需要数小时才能完成.我怀疑这是因为我与其他几个数据库用户竞争,数据库陷入困境.
8000个较小的查询在col2期间获得col1的计数.
SELECT
count(col1) as count
WHERE
col2 < 20121109
AND
col2 > 20121108
Run Code Online (Sandbox Code Playgroud)
我也开始玩这个maxrows属性,看看我是否可以通过这种方式识别任何信息.

更新
所以这不是cfquery的限制.通过使用QueryNew然后循环它来添加数据,我可以很好地超过200万标记没有任何问题.
我还使用此问题中的信息创建了一个ThinClient数据源,我没有观察到行为的任何变化.
数据库端的消息是
来自客户端的SQL*Net消息
和
SQL*Net向客户端提供更多数据
我刚刚发现通过使用瘦客户端,blockfactor1="100" …
我正在尝试使用以下代码插入CLOB。
cursor = connection.cursor()
cursor.setinputsizes(HERP = cx_Oracle.CLOB)
cursor.execute("INSERT INTO myTable (FOO, BAR) VALUES (:FOO, :BAR)", FOO=val1, BAR=val2)
cursor.execute("INSERT INTO myTable2 (HERP) VALUES (:HERP)", HERP=val3)
#len(HERP) 39097
Run Code Online (Sandbox Code Playgroud)
当我运行脚本WITHOUT时,cursor.setinputsizes(HERP = cx_Oracle.CLOB)它在第二个查询WITH上失败ValueError: string data too large,当我运行脚本时cursor.setinputsizes(HERP = cx_Oracle.CLOB),在第一个查询中使用失败DatabaseError: ORA-01036: illegal variable name/number。我尝试插入的CLOB包含一个代码段(即,它具有很多分号,逗号和括号),"string".decode("ascii")返回u'string',所以unicode并不是问题...对吗?我不知道这些东西是否有问题。数据库中的字段当前是一个CLOB,但是我已经使用NCLOB进行了尝试,并且行为没有改变。
我也尝试将字段作为BLOB使用,然后.encode("hex")在我插入的值上使用,再次出现相同的行为。
我也尝试过,HERP = cursor.var(cx_Oracle.CLOB)而不是cursor.setinputsizes(HERP = cx_Oracle.CLOB),同样的问题。
我一直在讨论cx-oracle-users列表上的讨论,但还没有走运。
如果我使用这一行cursor.execute("INSERT INTO myTable2 (HERP) VALUES (:HERP)", HERP="".join(set(val3)).encode("hex")),它将起作用,因此我认为这与数据内容无关(这与BLOB有关)。
如何cx_Oracle将CLOB插入Oracle数据库?
我期待mpmath在Python数组上执行元素操作.例如,
import mpmath as mpm
x = mpm.arange(0,4)
y = mpm.sin(x) # error
Run Code Online (Sandbox Code Playgroud)
或者,使用mpmath矩阵
x = mpm.matrix([0,1,2,3])
y = mpm.sin(x) # error
Run Code Online (Sandbox Code Playgroud)
mpmath在这个领域是否有任何能力,或者是否有必要循环参赛作品?
这是我到目前为止正在使用的内容
def f(n):
return n
f.__call__ = lambda n: n + 1
print f(2) #I expect an output of 3 but get an output of 2
Run Code Online (Sandbox Code Playgroud)
我对实现所需输出的另一种方式不感兴趣.相反,出于教育目的,我想知道为什么压倒__call__我所做的,并不像我期望的那样工作.
这是一个重现该问题的复制粘贴示例。
import logging
from flask import Flask
from werkzeug.serving import run_simple
from werkzeug.wsgi import DispatcherMiddleware
def app_builder(app_name, log_file):
app = Flask(app_name)
app.debug = True
handler = logging.FileHandler(log_file)
handler.setLevel(logging.DEBUG)
app.logger.addHandler(handler)
return app
def _simple(env, resp):
resp(b'200 OK', [(b'Content-Type', b'text/plain')])
return [b'root']
if __name__ == "__main__":
app = app_builder(app_name='app', log_file='app.log')
@app.route('/')
def index():
return '<a href="/app/error">click for error</a>'
@app.route('/error')
def error():
1/0
return 'error page'
app2 = app_builder(app_name='app2', log_file='app2.log')
@app2.route('/')
def index():
return 'you are getting responses from app2'
app.debug = True …Run Code Online (Sandbox Code Playgroud) 经过一些研究,这里有一个代码示例,我认为应该容易受到Billion Laughs攻击.然而它似乎没有工作,Done.太快地打印到控制台(从人类的角度来看).
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.InputSource;
public class BillionLOLs {
public static void vuln(String xml) {
try{
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(new InputSource(new StringReader(xml)));
Element root = doc.getDocumentElement();
} catch (Exception e){
}
}
public static void main(String[] args){
String xml =
"<?xml version=\"1.0\"?>"
+ "<!DOCTYPE lolz ["
+ "<!ENTITY lol \"lol\">"
+ "<!ENTITY lol2 \"&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;\">"
+ "<!ENTITY lol3 \"&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;\">"
+ "<!ENTITY lol4 …Run Code Online (Sandbox Code Playgroud) 通过我提供的示例,我希望index.cfm能够显示hello
我该怎么做?
的Application.cfc
<cfcomponent>
<cfset this.sessionManagement = true />
<cffunction name="onSessionStart">
<cfset SESSION.myVar = "hello">
</cffunction>
</cfcomponent>
Run Code Online (Sandbox Code Playgroud)
index.cfm
<html>
<head>
<title>Testing</title>
</head>
<body>
<cfoutput>#SESSION.myVar#</cfoutput>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我发现当我添加时
<cfinvoke component="Application" method="onSessionStart">
Run Code Online (Sandbox Code Playgroud)
它的工作原理是index.cfm,但每次刷新页面时都会覆盖所有变量.
所以我正在阅读一些ColdFusion 代码,然后我遇到了一个在它前面有美元符号的函数$myFunction.我想知道这是否是一些ColdFusion约定,如果没有那么使用这种编码风格的目的是什么?