blog posts

databases (1) django (1) drupal (2) java (4) processing (7) wamp (1) yahoo pipes (1)

Monday, 10 January 2011

Configure Django Database sqlite3 for Windows 7

to settup the database for Django
step 1: go to the settings file
 ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'mysite.db',                      # Or path to database file if using sqlite3.

for sqlight3 you just need to state the engine as sqlite3

type the command
python manage.py syncdb
remmeber the name of the database is just the name of the directory of your project in my case mysite.db

if everthing works you should get ouput simular to this image

The next step is to create your database tables to achieve this you need
to enter the command
python manage.py sql polls

BEGIN;
CREATE TABLE "polls_poll" (
    "id" serial NOT NULL PRIMARY KEY,
    "question" varchar(200) NOT NULL,
    "pub_date" timestamp with time zone NOT NULL
);
CREATE TABLE "polls_choice" (
    "id" serial NOT NULL PRIMARY KEY,
    "poll_id" integer NOT NULL REFERENCES "polls_poll" ("id"),
    "choice" varchar(200) NOT NULL,
    "votes" integer NOT NULL
);
COMMIT;
you should get to simular output to what is shown above
now you need to run the syncdb again to create those tables in the database. 
python manage.py syncd 
it will tell you about the new fixtures that have been added 
eg the polls 

 

No comments:

Post a Comment

Popular Posts