Skip to content

Commit

Permalink
Merge pull request #1 from warnerpr/pwarner/django_1.8_support
Browse files Browse the repository at this point in the history
Django 1.8 support.  This breaks Django 1.7 support.
  • Loading branch information
kokon committed Jun 5, 2015
2 parents a56b778 + 0528d11 commit 553560c
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ django-mysql-pymysql

This is a Django database backend for MySQL, using the PyMySQL database adapter. It is intended to be a drop-in replacement for the built-in MySQLdb backend, and leverages quite a bit of its code.

It is currently experimental, and has been tested with Django 1.7.
It is currently experimental, and has been tested with Django 1.8.


Requirements
Expand Down
37 changes: 35 additions & 2 deletions src/mysql_pymysql/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@

from django.conf import settings
from django.db import utils
from django.db.backends import (utils as backend_utils, BaseDatabaseFeatures,
BaseDatabaseOperations, BaseDatabaseWrapper)
from django.db.backends.base.features import BaseDatabaseFeatures
from django.db.backends.base.operations import BaseDatabaseOperations
from django.db.backends.base.base import BaseDatabaseWrapper
from django.db.backends import utils as backend_utils
from django.db.backends.mysql.client import DatabaseClient
from django.db.backends.mysql.creation import DatabaseCreation
from mysql_pymysql.introspection import DatabaseIntrospection
Expand Down Expand Up @@ -438,6 +440,37 @@ class DatabaseWrapper(BaseDatabaseWrapper):
'iendswith': 'LIKE %s',
}

data_types = {
'AutoField': 'integer AUTO_INCREMENT',
'BinaryField': 'longblob',
'BooleanField': 'bool',
'CharField': 'varchar(%(max_length)s)',
'CommaSeparatedIntegerField': 'varchar(%(max_length)s)',
'DateField': 'date',
'DateTimeField': 'datetime',
'DecimalField': 'numeric(%(max_digits)s, %(decimal_places)s)',
'DurationField': 'bigint',
'FileField': 'varchar(%(max_length)s)',
'FilePathField': 'varchar(%(max_length)s)',
'FloatField': 'double precision',
'IntegerField': 'integer',
'BigIntegerField': 'bigint',
'IPAddressField': 'char(15)',
'GenericIPAddressField': 'char(39)',
'NullBooleanField': 'bool',
'OneToOneField': 'integer',
'PositiveIntegerField': 'integer UNSIGNED',
'PositiveSmallIntegerField': 'smallint UNSIGNED',
'SlugField': 'varchar(%(max_length)s)',
'SmallIntegerField': 'smallint',
'TextField': 'longtext',
'TimeField': 'time',
'UUIDField': 'char(32)',
'DateTimeField': 'datetime(6)',
'TimeField': 'time(6)',
}


Database = Database

def __init__(self, *args, **kwargs):
Expand Down
11 changes: 7 additions & 4 deletions src/mysql_pymysql/introspection.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.db.backends import BaseDatabaseIntrospection
from django.db.backends.base.introspection import BaseDatabaseIntrospection, TableInfo
from pymysql import ProgrammingError, OperationalError
from pymysql.constants import FIELD_TYPE
import re
Expand Down Expand Up @@ -30,9 +30,12 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
}

def get_table_list(self, cursor):
"Returns a list of table names in the current database."
cursor.execute("SHOW TABLES")
return [row[0] for row in cursor.fetchall()]
"""
Returns a list of table and view names in the current database.
"""
cursor.execute("SHOW FULL TABLES")
return [TableInfo(row[0], {'BASE TABLE': 't', 'VIEW': 'v'}.get(row[1]))
for row in cursor.fetchall()]

def get_table_description(self, cursor, table_name):
"Returns a description of the table, with the DB-API cursor.description interface."
Expand Down
2 changes: 1 addition & 1 deletion src/mysql_pymysql/schema.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.db.backends.schema import BaseDatabaseSchemaEditor
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
from django.db.models import NOT_PROVIDED


Expand Down

0 comments on commit 553560c

Please sign in to comment.