0

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--

3
  • Add the queries you are using for creating or altering the role. I already have a hunch. Commented Jun 17, 2018 at 10:50
  • Mind case-sensitivity.
    – Thomas
    Commented Jun 17, 2018 at 11:52
  • @EsaJokinen , I tried many queries but simply I can wrote this <br/> sudo su - postgres CREATE ROLE TCOYUKSEL superuser; ALTER ROLE TCOYUKSEL WITH LOGIN;
    – MiskinSensei
    Commented Jun 18, 2018 at 7:36

1 Answer 1

5

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;"
4
  • I couldn't save it as image , but It didn't work preview.ibb.co/gPWQ2y/hata2.jpg
    – MiskinSensei
    Commented Jun 18, 2018 at 8:40
  • Add lines near lines 73, 9 of your ozgur.py, and 130 of __init__.py. (Edit original question.) Commented Jun 18, 2018 at 9:00
  • ok I've added the original question, thanks in advance
    – MiskinSensei
    Commented 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. Commented Jun 18, 2018 at 12:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.