I got this error When I'm trying to run the Code.
Error
I searched the site like this problem
But It couldn't solve my problem.
When I'm trying to create superuser with my username (which is TCOYUKSEL) , It create another one with "tcoyuksel"
Error
ozgur.py Line 9 db = psycopg2.connect("dbname=news")
ozgur.py Line 73 get_pop_articles(), str("views"))
init.py Line 130 conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
--I didn't do anything with this file--
1 Answer 1
The role name is case sensitive, but with your queries it gets translated to lower case tcoyuksel
,
CREATE ROLE TCOYUKSEL superuser;
ALTER ROLE TCOYUKSEL WITH LOGIN;
as key words and unquoted identifiers are case insensitive (4.1.1. Identifiers and Key Words).
There is a second kind of identifier: the delimited identifier or quoted identifier. It is formed by enclosing an arbitrary sequence of characters in double-quotes (
"
). A delimited identifier is always an identifier, never a key word. So"select"
could be used to refer to a column or table named "select
", whereas an unquoted select would be taken as a key word and would therefore provoke a parse error when used where a table or column name is expected.
You need to use the quotes to bypass the normalization i.e. use TCOYUKSEL
as delimited identifier:
CREATE ROLE "TCOYUKSEL" superuser;
ALTER ROLE "TCOYUKSEL" WITH LOGIN;
If you run it directly from the command line, you need to double the quotes:
postgres "CREATE ROLE ""TCOYUKSEL"" superuser; ALTER ROLE ""TCOYUKSEL"" WITH LOGIN;"
-
I couldn't save it as image , but It didn't work preview.ibb.co/gPWQ2y/hata2.jpgMiskinSensei– MiskinSensei2018年06月18日 08:40:10 +00:00Commented Jun 18, 2018 at 8:40
-
Add lines near lines 73, 9 of your
ozgur.py
, and 130 of__init__.py
. (Edit original question.)Esa Jokinen– Esa Jokinen2018年06月18日 09:00:06 +00:00Commented Jun 18, 2018 at 9:00 -
ok I've added the original question, thanks in advanceMiskinSensei– MiskinSensei2018年06月18日 11:41:04 +00:00Commented Jun 18, 2018 at 11:41
-
The error is not on line
73
but somewhere near, where the username is passed. More lines required to investigate further.Esa Jokinen– Esa Jokinen2018年06月18日 12:13:57 +00:00Commented Jun 18, 2018 at 12:13
sudo su - postgres CREATE ROLE TCOYUKSEL superuser; ALTER ROLE TCOYUKSEL WITH LOGIN;