首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >django with django-pyodbc不在Server 2008上由syncdb创建任何表

django with django-pyodbc不在Server 2008上由syncdb创建任何表
EN

Stack Overflow用户
提问于 2014-02-10 16:09:46
回答 1查看 504关注 0票数 0

我遇到了一个奇怪的问题,在成功执行django syncdb操作之后,没有在Server 2008上创建任何表。

以下是控制台输出:

代码语言:javascript
复制
    Creating tables ...
    Creating table django_admin_log
    Creating table auth_permission
    Creating table auth_group_permissions
    Creating table auth_group
    Creating table auth_user_groups
    Creating table auth_user_user_permissions
    Creating table auth_user
    Creating table django_content_type
    Creating table django_session

    You just installed Django's auth system, which means you don't have any superusers defined.
    Would you like to create one now? (yes/no): yes
    Username (leave blank to use 'xxx'): admin
    Email address: xxx@gmail.com
    Password: admin
    Password (again): admin
    Superuser created successfully.
    Installing custom SQL ...
    Installing indexes ...
    Installed 0 object(s) from 0 fixture(s)
    Finished "E:\Users\xxx\Documents\Eclipse Workspace\PyDev\chaos\manage.py syncdb" execution.

以下是我对django的settings.py:

代码语言:javascript
复制
    # SQL Server 2008
    DATABASES = {
        'default': {
            'ENGINE': 'django_pyodbc',
            'HOST': 'localhost',
            'NAME': 'Chaos',
            'USER': 'chaos',
            'PASSWORD': 'admin',
            'OPTIONS': {
                'driver': 'SQL Server Native Client 10.0',
                'MARS_Connection': True,
            },
        }
    }

请帮助找出根本原因。谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-02-20 13:34:23

这几天我遇到了这个问题。

然后我找到了这个https://github.com/lionheart/django-pyodbc/issues/38

Django 1.6现在假设自动提交默认为True,这意味着它必须显式地设置为使用1.6 (例如,syncdb看起来成功,但不创建任何表)。

解决方案是在选项中添加“autocommit”:True,如下所示:

代码语言:javascript
复制
    # SQL Server 2008
DATABASES = {
    'default': {
        'ENGINE': 'django_pyodbc',
        'HOST': 'localhost',
        'NAME': 'Chaos',
        'USER': 'chaos',
        'PASSWORD': 'admin',
        'OPTIONS': {
            'driver': 'SQL Server Native Client 10.0',
            'autocommit': True,
            'MARS_Connection': True,
        },
    }
}
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21682168

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档