From e320a0936e4c846e7332bcacc533dda19dad6783 Mon Sep 17 00:00:00 2001 From: Jacob Kaplan-Moss Date: Fri, 22 Jul 2005 03:15:43 +0000 Subject: Added sqlite3 database backend -- somewhat tested, but probably not 100% perfect. git-svn-id: http://code.djangoproject.com/svn/django/trunk@288 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/tutorial01.txt | 86 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 49 insertions(+), 37 deletions(-) (limited to 'docs/tutorial01.txt') diff --git a/docs/tutorial01.txt b/docs/tutorial01.txt index 1f14cd4e80..eb3c0eee45 100644 --- a/docs/tutorial01.txt +++ b/docs/tutorial01.txt @@ -49,23 +49,27 @@ settings. Let's look at what ``startproject`` created:: First, edit ``myproject/settings/main.py``. It's a normal Python module with module-level variables representing Django settings. Edit the file and change these settings to match your database's connection parameters: - -* ``DATABASE_ENGINE`` -- Either 'postgresql' or 'mysql'. More coming soon. -* ``DATABASE_NAME`` -- The name of your database. -* ``DATABASE_USER`` -- Your database username. -* ``DATABASE_PASSWORD`` -- Your database password. -* ``DATABASE_HOST`` -- The host your database is on. Leave this as an - empty string if your database server is on the same physical machine - (localhost). - -(Make sure you've created a database within PostgreSQL or MySQL by this point. -Do that with "``CREATE DATABASE database_name;``" within your database's -interactive prompt.) - -Also, note that MySQL support is a recent development, and Django hasn't been -comprehensively tested with that database. If you find any bugs in Django's -MySQL bindings, please file them in `Django's ticket system`_ so we can fix them -immediately. + + * ``DATABASE_ENGINE`` -- Either 'postgresql', 'mysql' or 'sqlite3'. + More coming soon. + * ``DATABASE_NAME`` -- The name of your database, or the full path to + the database file if using sqlite. + * ``DATABASE_USER`` -- Your database username (not used for sqlite). + * ``DATABASE_PASSWORD`` -- Your database password (not used for sqlite). + * ``DATABASE_HOST`` -- The host your database is on. Leave this as an + empty string if your database server is on the same physical machine + (not used for sqlite). + +.. admonition:: Note + + Make sure you've created a database within PostgreSQL or MySQL by this + point. Do that with "``CREATE DATABASE database_name;``" within your + database's interactive prompt. + + Also, note that MySQL and sqlite support is a recent development, and Django + hasn't been comprehensively tested with either database. If you find any + bugs in those bindings, please file them in `Django's ticket system`_ so we + can fix them immediately. Now, take a second to make sure ``myproject`` is on your Python path. You can do this by copying ``myproject`` to Python's ``site-packages`` directory, @@ -90,8 +94,9 @@ On Windows, you'd use ``set`` instead:: If you don't see any errors after running ``django-admin.py init``, you know it worked. That command initialized your database with Django's core database -tables. If you're interested, run the PostgreSQL or MySQL command-line client -and type "\\dt" (PostgreSQL) or "SHOW TABLES;" (MySQL) to display the tables. +tables. If you're interested, run the command-line client for your database and +type ``\\dt`` (PostgreSQL), ``SHOW TABLES;`` (MySQL), or ``.schema`` (SQLite) to +display the tables. Now you're set to start doing work. You won't have to take care of this boring administrative stuff again. @@ -235,27 +240,34 @@ You should see the following (the CREATE TABLE SQL statements for the polls app) Note the following: -* Table names are automatically generated by combining the name of the app - (polls) with a plural version of the object name (polls and choices). (You - can override this behavior.) -* Primary keys (IDs) are added automatically. (You can override this, too.) -* The foreign key relationship is made explicit by a ``REFERENCES`` statement. -* It's tailored to the database you're using, so database-specific field types - such as ``auto_increment`` (MySQL) vs. ``serial`` (PostgreSQL) are handled - for you automatically. The author of this tutorial runs PostgreSQL, so the - example output is in PostgreSQL syntax. + * Table names are automatically generated by combining the name of the app + (polls) with a plural version of the object name (polls and choices). (You + can override this behavior.) + + * Primary keys (IDs) are added automatically. (You can override this, too.) + + * The foreign key relationship is made explicit by a ``REFERENCES`` statement. + + * It's tailored to the database you're using, so database-specific field types + such as ``auto_increment`` (MySQL), ``serial`` (PostgreSQL), or ``integer + primary key`` (SQLite) are handled for you automatically. The author of + this tutorial runs PostgreSQL, so the example output is in PostgreSQL + syntax. If you're interested, also run the following commands: -* ``django-admin.py sqlinitialdata polls`` -- Outputs the initial-data inserts - required for Django's admin framework. -* ``django-admin.py sqlclear polls`` -- Outputs the necessary ``DROP TABLE`` - statements for this app, according to which tables already exist in your - database (if any). -* ``django-admin.py sqlindexes polls`` -- Outputs the ``CREATE INDEX`` - statements for this app. -* ``django-admin.py sqlall polls`` -- A combination of 'sql' and - 'sqlinitialdata'. + * ``django-admin.py sqlinitialdata polls`` -- Outputs the initial-data + inserts required for Django's admin framework. + + * ``django-admin.py sqlclear polls`` -- Outputs the necessary ``DROP + TABLE`` statements for this app, according to which tables already exist + in your database (if any). + + * ``django-admin.py sqlindexes polls`` -- Outputs the ``CREATE INDEX`` + statements for this app. + + * ``django-admin.py sqlall polls`` -- A combination of 'sql' and + 'sqlinitialdata'. Looking at the output of those commands can help you understand what's actually happening under the hood. -- cgit v1.3