Forums

Problems creating a Postgres database

I just upgraded my account to get Postgres capabilities, but I can't seem to get a database set up. I opened up a psql shell and did:

CREATE DATABASE tunisiya_dev

And nothing happens. I just get the prompt (postgres=# ) again, and if I try to make a migration it says the database doesn't exist. I don't see it listed in my databases tab, like the MySql ones are. In fact, I don't even see the default database listed.

I also had to install psycopg2 into my virtual envelope (which is running Django 1.8) — is that normal? It seems to me that the package that makes Postgres work with Django would be part of the "batteries included", which makes me wonder if something is wrong.

~Karen

PS — Just out of curiosity, why is the Postgres so expensive? After adding it, PAW costs twice what my current host does ($10/mo. on WebFaction). WebFaction includes it by default, so it's the only database I've ever used and I didn't realize there was anything special about it.

Try putting a semicolon at the end:

CREATE DATABASE tunisiya_dev;

That should work for you! You need to remember to put a semicolon at the end of all your SQL commands or they won't execute.

Also, in my experience, adding psycopg2 is standard practice to get Postgres working.

Hi there,

@hylton is right about SQL needing semicolons -- hope that helped?

re: "batteries included", we install a whole heap of packages, including psycopg2, into what's called the "system python". So if you open a Bash console and type "import psycopg2", it will work. But once you're using a virtualenv, you're isolated from the system python, so you have to install everything manually, there are no batteries included. The reason it's a good idea to use a virtualenv is because you might want different versions of packages from what we have in our batteries included -- our system versions of django are a little out of date for example.

re: why postgres is expensive, it's a reflection of the amount of work it took us to implement, as well as the amount of value people see in it. Sqlite costs us nothing at all, and supporting mysql was pretty easy, so both of those are essentially free. Postgres took us a while to get right, and it's also seen as a higher-quality database than either sqlite or mysql, so we charge a bit more for it.

google "postgres vs mysql" and you'll find any amount of rants on the topic. Personally I think it's all probably a little overblown...

DOH!

Yep, you all were right — I was just missing the semicolon.

Thanks for the explanation about psycopg2. I've been using Python/Django for a few years but this is my first time working with virtualenv and git, so I'm still trying to wrap my head around all that. And it is nice to be able to get the more up-to-date versions of the packages — there was no way I was missing out on migrations once I found out that 1.7+ had them. My model is starting out with two fields (Arabic word and translation), but it'll probably end up with 30 fields by the time I'm done building the system and we're working on the print dictionary. But I want to add each field carefully and deliberately, so I can make sure each one is necessary and the workflow is as efficient as possible. At the same time, we're going to be adding entries and working on them, so good migrations will be very important. And, from what I read, MySql does not handle migrations very well, so Postgres is probably worth the money.

And PAW is definitely worth the money to me ... I never want to hear the words "Python Path" again. Whenever I tried to do anything new on my machine, just getting things up and running took way more time than it should have and was usually a huge pain in the ass. So I'm just happy not to have to deal with all that ...