Git Product home page Git Product logo

django-pyodbc's Introduction

django-pyodbc

version_ โ€ƒ downloads_

django-pyodbc is a Django SQL Server DB backend powered by the pyodbc library. pyodbc is a mature, viable way to access SQL Server from Python in multiple platforms and is actively maintained. It's also used by SQLAlchemy for SQL Server connections.

This is a fork of the original django-pyodbc, hosted on Google Code and last updated in 2011.

Features

  • Support for Django 1.4 and up.
  • Support for SQL Server 2000, 2005, 2008, and 2012 (please let us know if you have success running this backend with another version of SQL Server)
  • Native Unicode support. Every string that goes in is stored as Unicode, and every string that goes out of the database is returned as Unicode. No conversion to/from intermediate encodings takes place, so things like max_length in CharField works just like expected.
  • Both Windows Authentication (Integrated Security) and SQL Server Authentication.
  • LIMIT+OFFSET and offset w/o LIMIT emulation under SQL Server 2005.
  • LIMIT+OFFSET under SQL Server 2000.
  • Django's TextField both under SQL Server 2000 and 2005.
  • Passes most of the tests of the Django test suite.
  • Compatible with SQL Server and SQL Server Native Client from Microsoft (Windows) and FreeTDS ODBC drivers (Linux).

Issues

Installation

  1. Install django-pyodbc.

    pip install django-pyodbc
  2. Now you can now add a database to your settings using standard ODBC parameters.

    DATABASES = {
       'default': {
           'ENGINE': "django_pyodbc",
           'HOST': "127.0.0.1,1433",
           'USER': "mssql_user",
           'PASSWORD': "mssql_password",
           'NAME': "database_name",
           'OPTIONS': {
               'host_is_server': True
           },
       }
    }
  3. That's it! You're done.

Configuration

The following settings control the behavior of the backend:

Standard Django settings

NAME String. Database name. Required.

HOST String. SQL Server instance in server\instance or ip,port format.

USER String. Database user name. If not given then MS Integrated Security

will be used.

PASSWORD String. Database user password.

OPTIONS Dictionary. Current available keys:

  • driver

    String. ODBC Driver to use. Default is "SQL Server" on Windows and "FreeTDS" on other platforms.

  • dsn

    String. A named DSN can be used instead of HOST.

  • autocommit

    Boolean. Indicates if pyodbc should direct the the ODBC driver to activate the autocommit feature. Default value is False.

  • MARS_Connection

    Boolean. Only relevant when running on Windows and with SQL Server 2005 or later through MS SQL Server Native client driver (i.e. setting driver to "SQL Server Native Client 11.0"). See http://msdn.microsoft.com/en-us/library/ms131686.aspx. Default value is False.

  • host_is_server

    Boolean. Only relevant if using the FreeTDS ODBC driver under Unix/Linux.

    By default, when using the FreeTDS ODBC driver the value specified in the HOST setting is used in a SERVERNAME ODBC connection string component instead of being used in a SERVER component; this means that this value should be the name of a dataserver definition present in the freetds.conf FreeTDS configuration file instead of a hostname or an IP address.

    But if this option is present and it's value is True, this special behavior is turned off.

    See http://freetds.org/userguide/dsnless.htm for more information.

  • extra_params

    String. Additional parameters for the ODBC connection. The format is "param=value;param=value".

  • collation

    String. Name of the collation to use when performing text field lookups against the database. For Chinese language you can set it to "Chinese_PRC_CI_AS". The default collation for the database will be used if no value is specified.

  • encoding

    String. Encoding used to decode data from this database. Default is 'utf-8'.

  • driver_needs_utf8

    Boolean. Some drivers (FreeTDS, and other ODBC drivers?) don't support Unicode yet, so SQL clauses' encoding is forced to utf-8 for those cases.

    If this option is not present, the value is guessed according to the driver set.

Tests

To run the test suite:

python tests/runtests.py --settings=test_django_pyodbc

License

See LICENSE.

Credits

From the original project README.

  • All the Django core developers, especially Malcolm Tredinnick. For being an example of technical excellence and for building such an impressive community.
  • The Oracle Django team (Matt Boersma, Ian Kelly) for some excellent ideas when it comes to implement a custom Django DB backend.

django-pyodbc's People

Contributors

avidal avatar dlo avatar elver avatar gorah avatar gotenxiao avatar hobson avatar jbittel avatar jieter avatar jordanorc avatar martingalloar avatar michiya avatar opencoderx avatar padelt avatar soujiro86 avatar tax avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.