小编che*_*gat的帖子

无法使用pymssql连接到SQL Server数据库,但可以使用底层freetds tsql连接

我不知道为什么我收到此错误,无法找到任何解决方案.我可以使用freetds tsql连接到SQL Server数据库,但在连接时我一直收到错误pymssql.connect.

具体错误是:

pymssql.OperationalError:(18456,"登录失败,用户'xxx'.DB-Lib错误消息18456,严重级14:\n一般SQL Server错误:检查来自SQL Server \nDB-Lib错误消息20002的消息,严重性9:\nAdaptive Server连接失败\n")

我将freetds的配置设置为:

[custom_config]
    host = myhost
    port = 1433
    tds version = 7.0
    encryption = request
    dump file = /tmp/freetds.log
Run Code Online (Sandbox Code Playgroud)

运行:

tsql -S custom_config -U tsmv -P xxx
Run Code Online (Sandbox Code Playgroud)

收益:

locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
1>
Run Code Online (Sandbox Code Playgroud)

这允许我查询数据库.

但是,运行:

python
>> import pymssql
>> pymssql.connect(server='custom_config', user='user', password='xxx',    database='database')
Run Code Online (Sandbox Code Playgroud)

提出上述错误.

我使用的是Linux CentOS,python 2.6.6,freetds 0.92 dev(我尝试过用tdsver = 7.0编译的其他版本).

freetds日志是:

log.c:196:Starting log file for FreeTDS 0.92
on 2012-04-12 10:39:15 …
Run Code Online (Sandbox Code Playgroud)

t-sql sql-server freetds pymssql

14
推荐指数
1
解决办法
3万
查看次数

Internet Explorer 10和Internet Explorer 11中的HTML5数字输入字段步骤属性已中断

当我尝试将值插入到带有步骤属性集的数字类型的输入字段时,我的网站的某些用户似乎遇到了问题.

我正在使用Django 1.6将表单呈现为HTML.

数字字段映射到基础DecimalField模型字段,其中max_digits = 25,decimal_places = 5

这导致以下示例html呈现为数字字段:

<input type="number" value="" step="0.00001" name="quantity" id="id_quantity">
Run Code Online (Sandbox Code Playgroud)

我知道的step属性在FireFox中尚不支持,但在Opera,Chrome,Safari和IE10 +中

除了IE10和IE11之外,所有浏览器都能正常运行.在上面的示例中,IE10和IE11中可输入的最大范围是-227到227.如果我尝试输入比此更低或更高的值,我会收到"您必须输入有效值"错误,并且无法提交表单.

根据http://www.w3schools.com/tags/att_input_step.asp

step属性指定元素的合法数字间隔.

示例:如果step ="3",则合法数字可以是-3,0,3,6等.

因此,在我的用户示例中,他们尝试输入20000作为IE10和IE11中失败的值.如果我的计算正确20000正确地落入0.00001的区间

对我来说,一个解决方案可能是从我所有使用数字字段的表单中删除step属性,可以通过django表单或使用javascript,但我认为这将是一个非常混乱的解决方案,并且与HTML5格式相悖.

有没有其他人遇到类似的问题,我做错了什么或这是IE10和IE11中的错误?

欢迎任何想法,评论或答案.与此同时,我将被迫通过建议使用可用的浏览器向受影响的用户提供我常用的解决方案.

forms django html5 internet-explorer-10 internet-explorer-11

10
推荐指数
3
解决办法
8737
查看次数

Django AttributeError:'str'对象没有属性'_default_manager'

以下错误似乎在我的实时服务器上随机发生(即通过apache mod_wsgi)但从未在开发中(即localhost python manage.py runserver).

请注意,这种情况很少发生,并且不是可以轻松复制的内容,也不是每次访问特定网址时都可以复制的内容.

我已经看到在SO和谷歌上发布的各种答案,但似乎没有任何明确的原因,为什么会出现这种错误.也许这是因为错误是相当通用的,但最常见的答案似乎是由于循环导入错误.我看到的另一个答案是模型FK字段引用不是正确的情况(例如applabel.model而不是applabel.Model),但我的所有模型FK字段都是正确的.

错误的原因似乎指向我的一个admin.py文件.此文件最初从forms.py文件导入自定义表单类.admin.py文件和forms.py文件都从models.py文件中导入了相同的模型.因此,我将表单类移动到admin.py文件,以防此处出现循环引用但我偶尔会遇到这些错误.

任何人都可以解释为什么会出现这种错误以及为什么这么错误?我始终确保在代码更新后重新启动相关服务.

回溯是:

Traceback (most recent call last):

File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 101, in get_response
request.path_info)

File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 250, in resolve
for pattern in self.url_patterns:

File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 279, in _get_url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)

File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 274, in _get_urlconf_module
self._urlconf_module = import_module(self.urlconf_name)

File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)

File "/myproject/urls.py", line 6, in <module>
admin.autodiscover()

File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/__init__.py", line 26, in autodiscover
import_module('%s.admin' % app)

File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in …
Run Code Online (Sandbox Code Playgroud)

django circular-reference attributeerror

5
推荐指数
3
解决办法
1万
查看次数