What’s the default superuser username/password for postgres after a new install?

CAUTION The answer about changing the UNIX password for “postgres” through “$ sudo passwd postgres” is not preferred, and can even be DANGEROUS! This is why: By default, the UNIX account “postgres” is locked, which means it cannot be logged in using a password. If you use “sudo passwd postgres”, the account is immediately unlocked. … Read more

Postgres: INSERT if does not exist already

I’m using Python to write to a postgres database: But because some of my rows are identical, I get the following error: How can I write an ‘INSERT unless this row already exists’ SQL statement? I’ve seen complex statements like this recommended: But firstly, is this overkill for what I need, and secondly, how can … Read more

PG COPY error: invalid input syntax for integer

ERROR: invalid input syntax for integer: “” “” isn’t a valid integer. PostgreSQL accepts unquoted blank fields as null by default in CSV, but “” would be like writing: and fail for the same reason. If you want to deal with CSV that has things like quoted empty strings for null integers, you’ll need to feed it to PostgreSQL via … Read more

psql: FATAL: database “” does not exist

It appears that your package manager failed to create the database named $user for you. The reason that works for you is that template1 is a database created by postgres itself, and is present on all installations. You are apparently able to log in to template1, so you must have some rights assigned to you … Read more