All Projects → lionheart → Django Pyodbc

lionheart / Django Pyodbc

Licence: apache-2.0
An ODBC-powered MS SQL Server DB backend for Django 1.4+

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to Django Pyodbc

django-pyodbc-azure
Django backend for Microsoft SQL Server and Azure SQL Database using pyodbc
Stars: ✭ 327 (+68.56%)
Mutual labels:  odbc
Eosio sql plugin
EOSIO sql database plugin
Stars: ✭ 21 (-89.18%)
Mutual labels:  odbc
Qtl
A friendly and lightweight C++ database library for MySQL, PostgreSQL, SQLite and ODBC.
Stars: ✭ 92 (-52.58%)
Mutual labels:  odbc
Rdbc
Rust DataBase Connectivity (RDBC) :: Common Rust API for database drivers
Stars: ✭ 328 (+69.07%)
Mutual labels:  odbc
Mdbtools
MDB Tools - Read Access databases on *nix
Stars: ✭ 616 (+217.53%)
Mutual labels:  odbc
Odbc adapter
An ActiveRecord ODBC adapter
Stars: ✭ 36 (-81.44%)
Mutual labels:  odbc
ODBC.jl
An ODBC interface for the Julia programming language
Stars: ✭ 81 (-58.25%)
Mutual labels:  odbc
Nanodbc
A small C++ wrapper for the native C ODBC API | Requires C++14 since v2.12
Stars: ✭ 175 (-9.79%)
Mutual labels:  odbc
Thingsboard Gateway
Open-source IoT Gateway - integrates devices connected to legacy and third-party systems with ThingsBoard IoT Platform using Modbus, CAN bus, BACnet, BLE, OPC-UA, MQTT, ODBC and REST protocols
Stars: ✭ 796 (+310.31%)
Mutual labels:  odbc
Xeus Sql
xeus-sql is a Jupyter kernel for general SQL implementations.
Stars: ✭ 85 (-56.19%)
Mutual labels:  odbc
Kyuubi
Kyuubi is a unified multi-tenant JDBC interface for large-scale data processing and analytics, built on top of Apache Spark
Stars: ✭ 363 (+87.11%)
Mutual labels:  odbc
Turbodbc
Turbodbc is a Python module to access relational databases via the Open Database Connectivity (ODBC) interface. The module complies with the Python Database API Specification 2.0.
Stars: ✭ 449 (+131.44%)
Mutual labels:  odbc
Mssqlex
Microsoft SQL Server Adapter for Elixir
Stars: ✭ 38 (-80.41%)
Mutual labels:  odbc
Odbc
Connect to ODBC databases (using the DBI interface)
Stars: ✭ 285 (+46.91%)
Mutual labels:  odbc
Clickhouse Odbc
ODBC driver for ClickHouse
Stars: ✭ 161 (-17.01%)
Mutual labels:  odbc
DolphinDBPlugin
No description or website provided.
Stars: ✭ 33 (-82.99%)
Mutual labels:  odbc
Soci
Official repository of the SOCI - The C++ Database Access Library
Stars: ✭ 960 (+394.85%)
Mutual labels:  odbc
Cidlib
The CIDLib general purpose C++ development environment
Stars: ✭ 179 (-7.73%)
Mutual labels:  odbc
Pyodbc
Python ODBC bridge
Stars: ✭ 2,270 (+1070.1%)
Mutual labels:  odbc
Zabbixdba
Zabbix Database Monitoring Service (Oracle, Pg, MySQL, MS SQL, DB2, etc.)
Stars: ✭ 68 (-64.95%)
Mutual labels:  odbc

django-pyodbc

|version|_

.. |version| image:: http://img.shields.io/pypi/v/django-pyodbc.svg?style=flat .. _version: https://pypi.org/project/django-pyodbc

django-pyodbc is a Django <http://djangoproject.com>_ SQL Server DB backend powered by the pyodbc <https://github.com/mkleehammer/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 <https://code.google.com/p/django-pyodbc/>_, hosted on Google Code and last updated in 2011.

Features

  • [x] Alpha support for Django 2.0 via pip install django-pyodbc>=2.0.0a1
  • [x] Support for Django 1.4-1.10.
  • [x] 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)
  • [x] Support for Openedge 11.6
  • [x] Support for IBM's DB2 <https://en.wikipedia.org/wiki/IBM_DB2>_
  • [x] 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.
  • [x] Both Windows Authentication (Integrated Security) and SQL Server Authentication.
  • [x] LIMIT+OFFSET and offset w/o LIMIT emulation under SQL Server 2005.
  • [x] LIMIT+OFFSET under SQL Server 2000.
  • [x] Django's TextField both under SQL Server 2000 and 2005.
  • [x] Passes most of the tests of the Django test suite.
  • [x] Compatible with SQL Server and SQL Server Native Client from Microsoft (Windows) and FreeTDS ODBC drivers (Linux).

TODO

  • [ ] Python 3 support. See #47 <https://github.com/lionheart/django-pyodbc/issues/47>_ for details.

Installation

  1. Install django-pyodbc.

    .. code:: python

    pip install django-pyodbc

  2. Now you can now add a database to your settings using standard ODBC parameters.

    .. code:: python

    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.*

    * You may need to configure your machine and drivers to do an ODBC <https://en.wikipedia.org/wiki/Open_Database_Connectivity>_ connection to your database server, if you haven't already. For Linux this involves installing and configuring Unix ODBC and FreeTDS <http://www.unixodbc.org/doc/FreeTDS.html>_ . Iterate on the command line to test your pyodbc <https://mkleehammer.github.io/pyodbc/>_ connection like:

    .. code:: python

    python -c 'import pyodbc; print(pyodbc.connect("DSN=foobar_mssql_data_source_name;UID=foo;PWD=bar").cursor().execute("select 1"))'
    

    extended instructions here <https://github.com/lionheart/django-pyodbc/issues/10>_

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.

``PORT`` String. SQL Server port.

``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.

* ``limit_table_list``

    Boolean.  This will restrict the table list query to the dbo schema.

* ``openedge``

    Boolean.  This will trigger support for Progress Openedge
    
* ``left_sql_quote`` , ``right_sql_quote``

    String.  Specifies the string to be inserted for left and right quoting of SQL identifiers respectively.  Only set these if django-pyodbc isn't guessing the correct quoting for your system.  
    
    
OpenEdge Support

For OpenEdge support make sure you supply both the deiver and the openedge extra options, all other parameters should work the same

Tests

To run the test suite:

.. code:: bash

python tests/runtests.py --settings=test_django_pyodbc

License

This project originally started life as django-sql-server. This project was abandoned in 2011 and was brought back to life as django-pyodbc by our team in 2013. In the process, most of the project was refactored and brought up to speed with modern Django best practices. The work done prior to the 2013 rewrite is licensed under BSD (3-Clause). Improvements since then are licensed under Apache 2.0. See LICENSE <LICENSE>_ for more details.

SemVer

This project implements Semantic Versioning <http://semver.org/>_ .

Credits

  • Aaron Aichlmayr <https://github.com/waterfoul>_
  • Adam Vandenber <javascript:; "For code to distinguish between different Query classes when subclassing them.">_
  • Alex Vidal <https://github.com/avidal>_
  • Dan Loewenherz <http://dlo.me>_
  • Filip Wasilewski <http://code.djangoproject.com/ticket/5246 "For his pioneering work, proving this was possible and profusely documenting the code with links to relevant vendor technical articles.">_
  • mamcx <http://code.djangoproject.com/ticket/5062>_ "For the first implementation using pymssql."
  • Michael Manfre <https://github.com/manfre>_
  • Michiya Takahashi <https://github.com/michiya>_
  • Paul Tax <https://github.com/tax>_
  • Ramiro Morales <http://djangopeople.net/ramiro/>_
  • Ross Rogers <https://github.com/RossRogers>_
  • Wei guangjing <http://djangopeople.net/vcc/>_

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.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].