Django

Code

Changeset 4749

Show
Ignore:
Timestamp:
03/16/07 10:42:58 (1 year ago)
Author:
adrian
Message:

Cleaned up docs/databases.txt

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/docs/databases.txt

    r4724 r4749  
    11=============================== 
    2 Notes About Supported Databases 
     2Notes about supported databases 
    33=============================== 
    44 
    5 Django attempts to support as many features as possible on all databases. 
    6 However, since not all database servers are identical, there is obviously 
    7 going to be some variations. This file describes some of the 
    8 features that might relevant to Django usage. It is not intended as a 
    9 replacement for server-specific documentation or reference manuals. 
     5Django attempts to support as many features as possible on all database 
     6backends. However, not all database backends are alike, and we've had to make 
     7design decisions on which features to support and which assumptions we can make 
     8safely. 
    109 
    11 MySQL Notes 
     10This file describes some of the features that might be relevant to Django 
     11usage. Of course, it is not intended as a replacement for server-specific 
     12documentation or reference manuals. 
     13 
     14MySQL notes 
    1215=========== 
    1316 
    1417Django expects the database to support transactions, referential integrity, 
    15 and Unicode support (UTF-8 encoding). Fortunately MySQL_ has all these 
     18and Unicode support (UTF-8 encoding). Fortunately, MySQL_ has all these 
    1619features as available as far back as 3.23. While it may be possible to use 
    17 3.23 or 4.0, you will probably have less trouble if you use 4.1 or 5.0. 
     203.23 or 4.0, you'll probably have less trouble if you use 4.1 or 5.0. 
    1821 
    19 MySQL-4.1 
     22MySQL 4.1 
    2023--------- 
    2124 
    22 MySQL-4.1_ has greatly improved support for character sets. It is possible to 
     25`MySQL 4.1`_ has greatly improved support for character sets. It is possible to 
    2326set different default character sets on the database, table, and column. 
    2427Previous versions have only a server-wide character set setting. It's also the 
    2528first version where the character set can be changed on the fly. 4.1 also has 
    26 support for views, but these are not currently used by Django
     29support for views, but Django currently doesn't use views
    2730 
    28 MySQL-5.0 
     31MySQL 5.0 
    2932--------- 
    3033 
    31 MySQL-5.0_ adds the ``information_schema`` database, which contains detailed 
    32 data on all database schema. This is used for Django's ``inspectdb`` feature, 
    33 when it is available. 5.0 also has support for stored procedures, but these 
    34 are not currently used by Django
     34`MySQL 5.0`_ adds the ``information_schema`` database, which contains detailed 
     35data on all database schema. Django's ``inspectdb`` feature uses this 
     36``information_schema`` if it's available. 5.0 also has support for stored 
     37procedures, but Django currently doesn't use stored procedures
    3538 
    3639.. _MySQL: http://www.mysql.com/ 
    37 .. _MySQL-4.1: http://dev.mysql.com/doc/refman/4.1/en/index.html 
    38 .. _MySQL-5.0: http://dev.mysql.com/doc/refman/5.0/en/index.html 
     40.. _MySQL 4.1: http://dev.mysql.com/doc/refman/4.1/en/index.html 
     41.. _MySQL 5.0: http://dev.mysql.com/doc/refman/5.0/en/index.html 
    3942 
    40 Storage Engines 
     43Storage engines 
    4144--------------- 
    4245 
     
    4447change the default storage engine in the server configuration. 
    4548 
    46 The default one is MyISAM_. The main drawback of MyISAM is that it does no
    47 currently have support for transactions or foreign keys. On the plus side, it 
    48 is currently the only engine that supports full-text indexing and searching. 
     49The default engine is MyISAM_. The main drawback of MyISAM is that it doesn'
     50currently support transactions or foreign keys. On the plus side, it's 
     51currently the only engine that supports full-text indexing and searching. 
    4952 
    5053The InnoDB_ engine is fully transactional and supports foreign key references. 
    5154 
    5255The BDB_ engine, like InnoDB, is also fully transactional and supports foreign 
    53 key references. However, it's use seems to be somewhat deprecated. 
     56key references. However, its use seems to be deprecated. 
    5457 
    5558`Other storage engines`_, including SolidDB_ and Falcon_, are on the horizon. 
     
    6770------- 
    6871 
    69 `MySQLdb`_ is the Python interface to MySQL. 1.2.1 is the first version which 
    70 has support for MySQL-4.1 and newer. If you are trying to use an older version 
    71 of MySQL, then 1.2.0 *may* work for you. 
     72`MySQLdb`_ is the Python interface to MySQL. 1.2.1 is the first version that 
     73has support for MySQL 4.1 and newer. If you are trying to use an older version 
     74of MySQL, then 1.2.0 *might* work for you. 
    7275 
    7376.. _MySQLdb: http://sourceforge.net/projects/mysql-python 
    7477 
    7578Creating your database 
    76 ~~~~~~~~~~~~~~~~~~~~~~ 
     79---------------------- 
    7780 
    7881You can `create your database`_ using the command-line tools and this SQL:: 
    7982 
    8083  CREATE DATABASE <dbname> CHARACTER SET utf8; 
    81    
    82 This ensures all tables and columns will use utf8 by default. 
    83    
     84 
     85This ensures all tables and columns will use UTF-8 by default. 
     86 
    8487.. _create your database: http://dev.mysql.com/doc/refman/5.0/en/create-database.html 
    8588 
    8689Connecting to the database 
    87 ~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     90-------------------------- 
    8891 
    8992Refer to the `settings documentation`_. 
     
    107110      'read_default_file': '/path/to/my.cnf', 
    108111      } 
    109        
     112 
    110113  # my.cnf 
    111114  [client] 
     
    115118  default-character-set = utf8 
    116119 
    117 There are several other MySQLdb connection options which may be useful, such 
    118 as ``ssl``, ``use_unicode``, ``init_command``, and ``sql_mode``; consult the 
     120Several other MySQLdb connection options may be useful, such as ``ssl``, 
     121``use_unicode``, ``init_command``, and ``sql_mode``. Consult the 
    119122`MySQLdb documentation`_ for more details. 
    120    
     123 
    121124.. _settings documentation: http://www.djangoproject.com/documentation/settings/#database-engine 
    122125.. _MySQL option file: http://dev.mysql.com/doc/refman/5.0/en/option-files.html 
     
    124127 
    125128Creating your tables 
    126 ~~~~~~~~~~~~~~~~~~~~ 
     129-------------------- 
    127130 
    128 When Django generates the schema, it doesn't specify a storage engine, so they 
    129 will be created with whatever default `storage engine`__ your database server 
    130 is configured for. The easiest solution is to set your database server's default 
    131 storage engine to the desired engine. 
     131When Django generates the schema, it doesn't specify a storage engine, so 
     132tables will be created with whatever default storage engine your database 
     133server is configured for. The easiest solution is to set your database server's 
     134default storage engine to the desired engine. 
    132135 
    133 __ `storage engines`_ 
    134  
    135 If you are using a hosting service and can't change your server's default 
     136If you're using a hosting service and can't change your server's default 
    136137storage engine, you have a couple of options. 
    137138 
    138 After the tables is created, all that is needed to convert it to a new storage 
    139 engine (such as InnoDB) is:: 
    140    
    141   ALTER TABLE <tablename> ENGINE=INNODB; 
     139    * After the tables are created, execute an ``ALTER TABLE`` statement to 
     140      convert a table to a new storage engine (such as InnoDB):: 
    142141 
    143 With a lot of tables, this can be tedious. 
     142          ALTER TABLE <tablename> ENGINE=INNODB; 
    144143 
    145 Another option is to use the ``init_command`` option for MySQLdb prior to 
    146 creating your tables:: 
     144      This can be tedious if you have a lot of tables. 
    147145 
    148   DATABASE_OPTIONS = { 
    149       ... 
    150       "init_command": "SET storage_engine=INNODB", 
    151       ... 
    152       } 
     146    * Another option is to use the ``init_command`` option for MySQLdb prior to 
     147      creating your tables:: 
    153148 
    154 This sets the default storage engine upon connecting to the database. After 
    155 your tables are set up and running in production, you should remove this 
    156 option. 
     149          DATABASE_OPTIONS = { 
     150              # ... 
     151             "init_command": "SET storage_engine=INNODB", 
     152              # ... 
     153          } 
    157154 
    158 Another method for changing the storage engine is described in 
    159 AlterModelOnSyncDB_. 
     155      This sets the default storage engine upon connecting to the database. 
     156      After your tables have been created, you should remove this option. 
     157 
     158    * Another method for changing the storage engine is described in 
     159      AlterModelOnSyncDB_. 
    160160 
    161161.. _AlterModelOnSyncDB: http://code.djangoproject.com/wiki/AlterModelOnSyncDB