On 12-07-06 8:56 AM, Houmie wrote:
Today I have started my first steps into postgresql, since its
recommended by the Django team.
I came across several issues, that I solved patiently one by one.
(disclaimer: I'm a Postgres homer)
These issues *should* come up with a well-designed database.
1) Creating tables under postgresql requires to login as a different
OS login, from which you don't even know the password. Fine, I found
the solution and created the database.
I'm guessing you are not there yet.
If using a system-supplied Postgres installation, there is likely a
pre-defined Postgres user. Some installations set this up as a nologin
account. But you can "su postgres" to have the right permissions to
start creating users (or roles) in the database.
You should define a user other than the postgres user to own the
database for your Django installation. Use the "createuser" command as
the postgres user, and make your first one the admin user for your
databases (give it the superuser permissions; createuser will ask you
about that). From then on you can use that account to interact with your
database, including creating tables and other users as needed.
Another way to do this is to create a separate installation. For the
server you just need to define PGDATA to point to your new data area
(with proper permissions; 700 for the top-level) and PGPORT as another
port number to avoid colliding with your default installation. For
clients you just need PGPORT and (possibly) PGHOST, but of course you
can also specify those in settings.py.
If you are using postgres, spend a few minutes to get familiar with the
docs. They are quite complete and should be your friend.
2) After running syncdb, you can't simply execute a simple insert sql
like this:
INSERT INTO App_contacttype (contact_type, company_id) VALUES
('Buyer', 1),('Seller', 1);
Who is using caps for "App_contacttype" in the first place? If you are
coming from MySQL then you should use the conversion program for that
(it used to be packaged with Postgres and probably still is).
Since Django creates it with quotes the table becomes case sensitive,
hence it has to be like this:
INSERT INTO "App_contacttype" (contact_type, company_id) VALUES
('Buyer', 1),('Seller', 1);
The SQL standard does not support mixed-case table or field names
without using quotes. That might be a reason to stay away from
mixed-case app names; thanks for discovering that for me ;)
But the problems seem never to end. Now suddenly the execution of the
insert script says
ERROR: value too long for type character varying(40)
SQL state: 22001
In MySQL this was no problem. I don't know, right now I am getting a
bit of cold feet, maybe I should just stick to MySQL.
Uh, if you have fields too long for the maximum length you defined
wouldn't you want to fix that? Either define the schema with a longer
field or switch to a text type.
The only reason I was considering postgresql was that some research
suggested postgresql has much better support for changing Schemas
along the way than MySQL.
There are (many) other reasons to consider postgresql. Don't give up;
there are just a few new things to pick up and you'll be using an
industrial-strength standards-compliant database which will scale as
well as any and better than most.
hth
- Tom
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.