Does pyodbc support any form of named parameters?

I know sqlite3 has data = {'test_col': 012345679} sqlite3_conn.execute(""" UPDATE test_db SET test_col = :test_col ;""", data) and mysql-connector-python has data = {'test_col': 012345679} mysql_conn.execute(""" UPDATE test_db SET test_col = %(test_col)s ;""", data) but does pyodbc support any form of named parameters? I like being able to just pass a dict to the execute meth

pyodbc是否支持任何形式的命名参数?

我知道sqlite3有 data = {'test_col': 012345679} sqlite3_conn.execute(""" UPDATE test_db SET test_col = :test_col ;""", data) 和mysql-connector-python有 data = {'test_col': 012345679} mysql_conn.execute(""" UPDATE test_db SET test_col = %(test_col)s ;""", data) 但pyodbc支持任何形式的命名参数? 我喜欢能够将一个dict传递给execute方法。 这非常方便,并且对于我的一些查询,如INSERT

Algorithm for finding minimal cycle basis of planar graph

I have a planar graph, where all nodes represent (X, Y) coordinates. The edges never intersect on the plane. The graph represents roads on of a city. Is there a Python library that provides an algorithm available for finding the minimal cycle basis, ie the enclosed regions. Or a relatively simple algorithm (efficiency is not the main problem currently) I'm currently using NetworkX, which

求平面图的最小循环基的算法

我有一个平面图,其中所有节点表示(X,Y)坐标。 边缘不会在飞机上相交。 该图表示一个城市的道路。 是否有Python库提供可用于查找最小循环基础的算法,即封闭区域。 或者一个相对简单的算法(效率目前不是主要问题)我目前使用NetworkX,它只有cycle_basis ,但在最小循环基础上没有功能。 我发现的唯一参考是这种算法,但我没有时间来完整地阅读/实现它。 等一下,如果图形实际上是一个城市的代表,那么已经有一个嵌入

Networkx: Use common function for edge weight calculation

Suppose I have a function euc_2d(graph, n1, n2) that calculates the euclidean distance between two nodes of the same graph. Each nodes has a given pos=(x,y) which is assigned on graph creation. NetworkX provides a function to get the total weight of all edges of a graph namely graph.size(weight='weight') . The problem with this method is that it assumes that whenever I add an edge I s

Networkx:使用通用功能进行边缘权重计算

假设我有一个函数euc_2d(graph, n1, n2)来计算同一个图的两个节点之间的欧氏距离。 每个节点都有一个给定的pos=(x,y) ,它是在图创建时分配的。 NetworkX提供了一个函数来获得图形所有边的总权重,即graph.size(weight='weight') 。 这个方法的问题是它假定每当我添加一个边时,我都应该使用lambda函数明确地指定适当的边权重,如graph.add_edge(u,v,weight=?) 。 然而,这是非常不方便的(并且冗长),因为我始终

Python Library/Module for (simple) Undirected Graphs

I've been searching the web for the past hour trying to find a library for python that will help me create and draw simple undirected graphs. It looks like NetworkX (http://networkx.lanl.gov/index.html) is by far the most popular one but unfortunately it doesn't support drawing for Python 3. Any suggestions? I don't need anything super powerful or complex, just basic (even undirec

用于(简单)无向图的Python库/模块

我一直在网上搜索过去一小时,试图找到一个python库,它可以帮助我创建和绘制简单的无向图。 它看起来像NetworkX(http://networkx.lanl.gov/index.html)是目前最流行的一种,但不幸的是它不支持Python 3的绘图。 有什么建议么? 我不需要任何超级强大或复杂的东西,只需要基本的(甚至是无向的)图形创建和绘图(也可以导出为png,jpeg等)。 你知道,只有几个节点和边缘。 NetworkX提到了很多使用Graphviz绘制图形的方

Check if Twisted Server launched with twistd was started successfully

I need a reliable way to check if a Twisted-based server, started via twistd (and a TAC-file), was started successfully. It may fail because some network options are setup wrong. Since I cannot access the twistd log (as it is logged to /dev/null, because I don't need the log-clutter twistd produces), I need to find out if the Server was started successfully within a launch-script which wrap

检查Twisted启动的Twisted Server是否成功启动

我需要一种可靠的方法来检查通过twistd(和TAC文件)启动的基于Twisted的服务器是否已成功启动。 它可能会失败,因为某些网络选项设置错误。 由于我无法访问twistd日志(因为它记录到/ dev / null,因为我不需要日志混乱的twistd产品),所以我需要确定Server是否在启动脚本中成功启动,该脚本包装扭打的电话。 启动脚本是这样的Bash脚本: #!/usr/bin/bash twistd --pidfile "myservice.pid" --logfile "/dev/null"

Twisted: disable logging of Twisted

My Twisted-based client sends UDP packets in a loop. Therefore I'm using the class DatagramProtocol. This is the source: #!/usr/bin/python # -*- coding: utf-8 -*- from twisted.application.service import Service from twisted.internet import reactor from twisted.internet.task import LoopingCall from twisted.internet.protocol import DatagramProtocol from twisted.python import log import loggi

扭曲:禁用Twisted的日志记录

我的基于Twisted的客户端循环发送UDP数据包。 因此我使用DatagramProtocol类。 这是来源: #!/usr/bin/python # -*- coding: utf-8 -*- from twisted.application.service import Service from twisted.internet import reactor from twisted.internet.task import LoopingCall from twisted.internet.protocol import DatagramProtocol from twisted.python import log import logging class HeartbeatClient(Service):

how to send data with twisted protocol via factory

I'm writing a client implementing a custom protocol, and have a factory for it. My problem is the following: my client has bi-dir communication, and sometimes I want to tell it "send this data". But all I have is the factory object: class MyFactory(ClientFactory): protocol = MyProtocol def __init__(self, recv_callback): self.recv_callback = recv_callback def

如何通过工厂以扭曲协议发送数据

我正在写一个实现自定义协议的客户端,并且有一个工厂。 我的问题如下:我的客户端有双向通信,有时我想告诉它“发送这些数据”。 但我拥有的是工厂对象: class MyFactory(ClientFactory): protocol = MyProtocol def __init__(self, recv_callback): self.recv_callback = recv_callback def send_message(self, msg): self.protocol.send_message(msg) 所以我创建了一个工厂并拥有一个工厂对

Pass multiple args from bash into python

I have a short inline python script that I call from a bash script, and I want to have it handle a multi-word variable (which comes from $* ). I expected this to just work: #!/bin/bash arg="A B C" python -c "print '"$arg"'" but it doesn't: File "<string>", line 1 print 'A ^ SyntaxError: EOL while scanning string literal Why? I would like to explain why your code

将bash中的多个参数传递给python

我有一个简短的内联python脚本,我从一个bash脚本调用,我想让它处理一个多字变量(来自$* )。 我预计这只是工作: #!/bin/bash arg="A B C" python -c "print '"$arg"'" 但它不: File "<string>", line 1 print 'A ^ SyntaxError: EOL while scanning string literal 为什么? 我想解释为什么你的代码不起作用。 你想要做的是: arg="A B C" python -c "print '""$arg""'" 输出: A B C

How do I check what version of Python is running my script?

如何检查Python解释器的哪个版本正在解释我的脚本? This information is available in the sys.version string in the sys module: >>> import sys Human readable: >>> print (sys.version) #parentheses necessary in python 3. 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] For further processing: >>> sys.version_info (2, 5, 2, 'final', 0)

如何检查Python的哪个版本正在运行我的脚本?

如何检查Python解释器的哪个版本正在解释我的脚本? 该信息在sys模块的sys.version字符串中可用: >>> import sys 人类可读: >>> print (sys.version) #parentheses necessary in python 3. 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] 进一步处理: >>> sys.version_info (2, 5, 2, 'final', 0) # or >>> sys.hexversion 34014192 要

Python ElementTree: ElementTree vs root Element

I'm a bit confused by some of the design decisions in the Python ElementTree API - they seem kind of arbitrary, so I'd like some clarification to see if these decisions have some logic behind them, or if they're just more or less ad hoc. So, generally there are two ways you might want to generate an ElementTree - one is via some kind of source stream, like a file, or other I/O strea

Python ElementTree:ElementTree vs根元素

我对Python ElementTree API中的一些设计决定感到有点困惑 - 它们看起来有些随意,所以我想澄清一下,看看这些决定是否有一些逻辑背后的原因,或者它们更多,或者不那么特别。 因此,通常有两种方法可能需要生成ElementTree - 一种是通过某种源流(如文件或其他I / O流)生成的。 这是通过parse()函数或ElementTree.parse()类的方法实现的。 另一种方法是直接从字符串对象加载XML。 这可以通过fromstring()函数完成。 好