Ubuntu Maverick w/Python 2.7:
我无法弄清楚如何解决以下导入错误:
>>> import ssl
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/ssl.py", line 60, in <module>
import _ssl # if we can't import it, let the error propagate
ImportError: No module named _ssl
Run Code Online (Sandbox Code Playgroud)
更新: 我重新编译了源代码.我无法弄清楚如何在下面提到的答案中添加--with-ssl选项,而是通过在/Modules/Setup.dist中编辑关于SSL的行来实现这一点.
假设我有以下语句,内连接产生3行,其中a.Id = b.Id,但3行中的每一行都有不同的b.Value.由于只更新了tableA中的一行,因此更新中使用了3个值中的哪一个?
UPDATE a
SET a.Value = b.Value
FROM tableA AS a
INNER JOIN tableB as b
ON a.Id = b.Id
Run Code Online (Sandbox Code Playgroud) 我正在使用python 2.7
我想创建一个围绕fcntl.flock()的包装函数,它将在设置的间隔后超时:
wrapper_function(timeout):
Run Code Online (Sandbox Code Playgroud)
我试过调用另一个线程并使用thread.join(超时),但似乎fcntl.flock()继续阻塞:
def GetLock(self, timeout):
"""Returns true if lock is aquired, false if lock is already in use"""
self.__lock_file = open('proc_lock', 'w')
def GetLockOrTimeOut():
print 'ProcessLock: Acquiring Lock'
fcntl.flock(self.__lock_file.fileno(), fcntl.LOCK_EX)
print 'ProcessLock: Lock Acquired'
thread = threading.Thread(target=GetLockOrTimeOut)
thread.start()
thread.join(timeout)
if thread.isAlive():
print 'GetLock timed out'
return False
else:
return True
Run Code Online (Sandbox Code Playgroud)
我已经研究了终止线程的解决方案,最流行的解决方案似乎是对threading.thread进行子类化并添加一个功能来引发线程中的异常.但是,我遇到一个链接,说这个方法不适用于本机调用,我很确定fcntl.flock()正在调用本机函数.建议?
上下文:我使用文件锁来创建单个实例应用程序,但我不希望应用程序的第二个实例坐下来并挂起,直到第一个实例终止.
我试图在一个测试我的连接为给定的连接字符串的方法中更改SqlCommand查询的超时.代码类似于:
using (SqlConnection connection = new SqlConnection(connectionString))
{
SqlCommand cmd = new SqlCommand("SELECT ...", connection);
cmd.CommandTimeout = 10;
connection.Open();
SqlDataReader reader = cmd.ExecuteReader();
...
connection.Close();
}
Run Code Online (Sandbox Code Playgroud)
我想在这里有一个短暂的超时,因为我只想测试这个连接字符串是否正常.但是,无论我在CommandTimeout上设置了什么号码(我尝试过0,1,2,4,10,30,60,120),我为虚拟连接字符串获得的实时总是大致相同(总运行时间约为15秒).
所以,在我看来,我在CommandTimeout上设置的值由于某种原因被忽略.
有什么想法吗?
我的老板要我在不久的将来创建一些报告,我想他想使用SQL Server Reporting Services来部署报告.考虑到我们是一个非常小的组织,我不太确定这将是一个好主意,我看不到我们正在充分利用或需要此解决方案提供的功能,如设置用户,组和订阅.
虽然我之前没有使用SSRS,但我已经观看了为期3天的网络研讨会,看起来这是一件很好的事情,对于简单的情况来说很好但是当需求变得更加复杂时会变得很痛苦并且受到限制.我会将报告部署为.net应用程序中的本地报告(.rdlc),因为:
所以我想我的问题是SSRS在什么情况下运作良好,哪些情况不好?我的观点是有效还是我只是怀疑论者?
在我的机器上,我有一个WSDL文件和所有必要的模式文件.我正在尝试使用svcutil从WSDL创建客户端代理代码.命令:
svcutil myfile.wsdl
Run Code Online (Sandbox Code Playgroud)
我在使用svcutil时遇到错误,但在使用soapUI加载wsdl时没有问题,如果这意味着什么.
我一直收到这个错误:
Error: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: Schema with target namespace 'http://www.crsoftwareinc.com/xml/ns/titanium/event/areventservice/v1_0' could not be found.
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://www.crsoftwareinc.com/xml/ns/titanium/event/areventservice/v1_0']/wsdl:portType[@name='areventservice']
Run Code Online (Sandbox Code Playgroud)
这是WSDL:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
name="areventservice"
targetNamespace="http://www.crsoftwareinc.com/xml/ns/titanium/event/areventservice/v1_0"
xmlns:tns="http://www.crsoftwareinc.com/xml/ns/titanium/event/areventservice/v1_0"
xmlns:es="http://www.crsoftwareinc.com/xml/ns/titanium/event/areventservice/v1_0">
<wsdl:types>
<xsd:schema targetNamespace="http://www.crsoftwareinc.com/xml/ns/titanium/event/areventservice/v1_0"
xmlns:tns="http://www.crsoftwareinc.com/xml/ns/titanium/event/areventservice/v1_0"
xmlns:es="http://www.crsoftwareinc.com/xml/ns/titanium/event/areventservice/v1_0">
<xsd:include schemaLocation="arevent-service.xsd"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="SaveAREventWithShortNames">
<wsdl:part element="es:save-arevent-with-shortnames" name="SaveAREventWithShortNames"/>
</wsdl:message>
<wsdl:message name="RetrieveAREventByConsumerIdentifier">
<wsdl:part element="es:retrieve-arevent-by-consumer-agency-identifier" name="RetrieveAREventByConsumerIdentifier"/>
</wsdl:message>
<wsdl:message name="RetrieveAREventByConsumerAccountIdentifier">
<wsdl:part element="es:retrieve-arevent-by-consumer-account-agency-identifier" name="RetrieveAREventByConsumerAccountIdentifier"/>
</wsdl:message>
<wsdl:message name="RetrieveAREventResponse">
<wsdl:part element="es:retrieve-arevent-response" name="RetrieveAREventResponse"/> …Run Code Online (Sandbox Code Playgroud) 如何调整以下查询以始终返回MemberID ='xxx'作为第一行的成员
SELECT*FROM Members
在下面的代码中,我有一个从网络流中读取的StreamReader.这段代码通常可以运行好几天.我遇到了一个问题,突然StreamReader.ReadLine()开始返回null.
根据Microsoft文档,StreamReader.ReadLine()在到达输入流的末尾时将返回null.当底层流是NetworkStream时,这对我没有意义.ReadLine()不应该阻塞直到网络流接收数据?
这是我第一次遇到这个问题而我无法复制它.什么可能导致这个?
背景信息:应用程序从电话交换机接收CDR记录.电话交换机连接到应用程序并发送普通的旧文本记录.在开关连接后,它将保持连接并继续发送永久记录,除非出现故障.
private void ProcessClient(TcpClient client)
{
try
{
using (NetworkStream stream = client.GetStream())
{
using (StreamReader reader = new StreamReader(stream))
{
//continue processing while service is on
while (m_RunService & client.Connected)
{
string curLine = reader.ReadLine();
//code here does stuff to string
//will catch any exceptions that have to do with
//processing the string
}
}
}
}
catch (Exception ex)
{
//write to log
}
}
Run Code Online (Sandbox Code Playgroud)
以下是启动侦听器的代码:
private void Listen()
{
try
{
while (m_RunService)
{ …Run Code Online (Sandbox Code Playgroud) 我有一个绑定到对象列表的列表框.对于每个列表项,我想要一个矩形,其填充颜色由绑定对象的一些属性决定.所以我做了以下事情:
这是有效的,但只是第一次对象的属性发生变化.之后,附加属性似乎在数据对象的属性更改时不会收到通知.我已经双重检查,我的数据对象正在引发INotifyPropertyChanged事件.可能是什么问题呢?
<Rectangle Style="{StaticResource RecordStateRectangleStyle}"
Width="10" Height="10" Stroke="Black"
local:RecordAttachment.RecordState="{Binding Path=RecordState}"
local:RecordAttachment.IsDeleted="{Binding Path=IsDeleted}" />
Run Code Online (Sandbox Code Playgroud)
风格:
<Style x:Key="RecordStateRectangleStyle" TargetType="Rectangle">
<Style.Resources>
<SolidColorBrush x:Key="AddedStateBrush" Color="LightGreen" Opacity=".8" />
<SolidColorBrush x:Key="ModifiedStateBrush" Color="Orange" Opacity=".8" />
<SolidColorBrush x:Key="DeletedStateBrush" Color="Red" Opacity=".8" />
</Style.Resources>
<Style.Triggers>
<Trigger Property="local:RecordAttachment.RecordState" Value="{x:Static model:RecordState.Added}">
<Setter Property="Fill" Value="{StaticResource AddedStateBrush}" />
</Trigger>
<Trigger Property="local:RecordAttachment.RecordState" Value="{x:Static model:RecordState.Modified}">
<Setter Property="Fill" Value="{StaticResource ModifiedStateBrush}" />
</Trigger>
<Trigger Property="local:RecordAttachment.IsDeleted" Value="true">
<Setter Property="Fill" Value="{StaticResource DeletedStateBrush}" />
</Trigger>
</Style.Triggers>
</Style>
Run Code Online (Sandbox Code Playgroud)
附属物类:
Public Class RecordAttachment
Public Shared ReadOnly RecordStateProperty As DependencyProperty …Run Code Online (Sandbox Code Playgroud) 我正在使用SQL Server 2005.
关于坏桌设计,请看这篇文章的结尾.
我有两列.我想按照第二列的顺序在第一列分组.微软文档声明GROUP BY子句不关心顺序,我该如何强制执行?
这是我的伪查询:
SELECT col_1,
MIN(col_2),
MAX(col_2)
FROM someTable
GROUP BY col_1 (*** WITH RESPECT TO ORDER OF col_2***)
Run Code Online (Sandbox Code Playgroud)
如果我在下表中运行查询:
Col_1 Col_2
A 1
A 2
A 3
B 4
C 5
C 6
B 7
A 9
Run Code Online (Sandbox Code Playgroud)
我应该得到以下结果:
Col_1 Min Max
A 1 3
B 4 4
C 5 6
B 7 7
A 9 9
Run Code Online (Sandbox Code Playgroud)
关键部分是我不能在结果集中将A的所有4条记录集中在一起.当查询表/子查询时,它按col_2排序,col_1的每个新实例都应该导致新的分组.谢谢,我找不到任何相关内容.
我可以做NOTHING与表的设计.这是一个由外部供应商创建的表,该表与其专有软件一起使用.我再说一遍,我对表设计无能为力!!!!
仅当单击鼠标时鼠标未在图像上方时,才会触发按钮命令.我错过了什么?
<Button Cursor="Hand" Command="{Binding Path=SomeCommand}">
<Image Source="image.png" />
</Button>
Run Code Online (Sandbox Code Playgroud) 我想根据数据库中时间戳字段的年份和月份在我的select语句中放置一个where子句
我有一个月和一年的下拉列表,它给了我以下字符串01/2012
我的数据库中的日期格式是"2012-01-01 00:00:00"但是当我选择一个单独的日期并将其放入消息框时,它会转换为"01/01/2012"
我已经修改了下面的选择语句以反映转换日期.但是我仍然没有给出正确的细节.有任何想法吗?在处理时间戳字段时是否需要使用特定格式?我甚至可以在select语句中使用"Right"函数吗?
Dim newRecordDate As String = val1 & "/" & ComboBox2.SelectedValue
Dim sql2 As String = "Select CatA, CatB, CatC, Cost, Currency, MarketingCode, Comment, RecordDate from vw_tblP_Usage_Details where puid = '" & puid & "' right(RecordDate, 7) = '" & newRecordDate & "'"
Run Code Online (Sandbox Code Playgroud) 我有一个内联表值函数,我想从select传递一个列,但将使用表别名.
例如:
select top 1000 a.*, b.* from item a
LEFT JOIN itemList b on a.item_id = b.item_id
where a.item_id in (SELECT * FROM dbo.fn_GIVFUC('1234567', a.item_id))
Run Code Online (Sandbox Code Playgroud)
结果:'a'附近的语法不正确.
谢谢
sql ×6
sql-server ×6
c# ×3
.net ×2
python ×2
vb.net ×2
wpf ×2
ado.net ×1
python-2.7 ×1
rdlc ×1
select ×1
svcutil.exe ×1
tcp ×1
wcf ×1