Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Oct 30 15:06

    steve-chavez on master

    fix non-variadic repeated param… (compare)

  • Oct 30 15:06
    steve-chavez closed #1639
  • Oct 30 14:21
    wolfgangwalther commented #1639
  • Oct 30 14:20
    wolfgangwalther synchronize #1639
  • Oct 29 23:59
    steve-chavez commented #1639
  • Oct 29 23:57
    steve-chavez commented #360
  • Oct 29 23:53

    steve-chavez on master

    refactor: reorder PgVersion(95/… refactor: add Hasql arrayColumn… Fix charset=utf-8 appending to … and 1 more (compare)

  • Oct 29 23:53
    steve-chavez closed #1636
  • Oct 29 20:27
    Pigeo commented #1638
  • Oct 29 20:04
    bradleyf opened #360
  • Oct 29 17:38
    dwagin commented #1633
  • Oct 29 07:06
    PsychicSimp commented #1637
  • Oct 29 07:05
    PsychicSimp closed #1637
  • Oct 29 07:05
    PsychicSimp commented #1637
  • Oct 29 06:11
    wolfgangwalther commented #1637
  • Oct 29 06:10
    wolfgangwalther commented #1637
  • Oct 29 04:45
    PsychicSimp commented #1637
  • Oct 28 20:42
    bradleyf closed #358
  • Oct 28 20:42
    bradleyf commented #358
  • Oct 28 20:27
    wolfgangwalther synchronize #1639
ofcaah
@ofcaah
Hello everyone, is there some way to switch GET requests to read/write transactions without hard recompiling PostgREST? I'm trying to use a pre_request function that extends user's session, does some logging, and switches the local role upon the user's session token, and most of those things will fail in a read only transaction. I tried doing 'set transaction' as a first thing in pre_request function, but it's already too late.
10 replies
Nikolai Lebedev
@nextstopsun
Hi, when POSTing to rpc function with an INSERT statement I get cannot execute INSERT in a read-only transaction. How can I fix this?
3 replies
Akshay Donga
@akshay.d1_gitlab
Hello folks.
Anyone has worked with PostgREST's object pattern change by JSON/JSONB.
I need help to change my actual object .
1 reply
Markus Duecker
@mduecker
Does anyone have experience running PostgREST with Amazon Aurora PostgreSQL?
3 replies
Beck Maxime
@maxime-beck

Hello, I am trying to persist a blob file into this table via PostREST :

CREATE TABLE "public"."document_content" (
ogc_fid SERIAL,
file bytea,
CONSTRAINT document_content_pk PRIMARY KEY (ogc_fid)
);

I have not find any examples on how to do this, is it supported?

Steve Chavez
@steve-chavez
@maxime-beck Right now it's only possible by base64 encoding the payload and then decoding it on the db. Check https://github.com/PostgREST/postgrest/issues/922#issuecomment-593945310.
bawidyantoro
@bawidyantoro
Hai everyone, I'm trying to use Postgrest. I want to retrieve data from the TomTom API and then enter it into the PostgreSQL database. Does anyone want to help how? before that, I want to install Postgrest on Windows OS, how do I do it? thanks.
1 reply
alsbevern
@alsbevern
Hi everyone, it try to use postgrest with some datatypes like inet and jsonb, how could i handle following operators?
'>>=' or '->>' from doc: https://www.postgresql.org/docs/9.3/functions-net.html or https://www.postgresql.org/docs/9.5/functions-json.html
Steve Chavez
@steve-chavez
>>= is not. It's unfortunate that pg didn't choose @> for the inet contains operation.
Only way for that to work would be an stored procedure. Or maybe you can create an operator alias for >>=.
gabrielsCloud
@gabrielsCloud

Hi everyone, I'm trying to use Postgrest on Ubuntu 1604 LTS. But, when I tried to access to Postgrest on the VPS in DigitalOcean.com I haven't access to port 3000. The params on config file are:
db-uri = "postgres://user:pass@IP:5432/database", db-schema = "public" ,db-anon-role = "postgres", db-pool = 10, db-pool-timeout = 10,
server-host = "*", server-port = 3000.

What I've doing wrong?

2 replies
ofcaah
@ofcaah

I have:
api.view_of_table
api.view_of_anothertable_from_otherschema
api.view_of_yetanothertable_from_otherschema
public.table
otherschema.anothertable
otherschema.yetanothertable

public.table(somefk references otherschema.anothertable (the_fk))
otherschema.yetanothertable (somefk references otherschema.anothertable (the_fk))

Should a request like table?select=*,view_of_anothertable(*),view_of_yetanothertable_from_otherschema(*) work in such case? PostgREST complains, that there's no relationship between table and yetanothertable

2 replies
Aryan Iyappan
@PsychicSimp
Hello
So I have been following tutorial 0
And I have a few doubts
this is what I did in the psql
CREATE SCHEMA api;

CREATE TABLE api.users(
    last_name TEXT,
    first_name TEXT,
    user_name TEXT UNIQUE,
    email TEXT UNIQUE,
    has_premium BOOLEAN DEFAULT FALSE,
    date_created TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
    user_id BIGINT GENERATED ALWAYS AS IDENTITY 
    (START WITH 10000000 INCREMENT BY 1) PRIMARY KEY
    );

CREATE TABLE api.passwords(
    encrypted_password TEXT,
    ref_user_id BIGINT,
    FOREIGN KEY(ref_user_id) REFERENCES api.users(user_id) ON DELETE CASCADE ON UPDATE CASCADE
    );

CREATE INDEX idx_user_id ON api.users(user_id);
CREATE INDEX idx_user_name ON api.users(user_name);

CREATE ROLE web_anon NOLOGIN;
GRANT web_anon TO postgres;

GRANT USAGE ON schema api TO web_anon;
GRANT SELECT ON api.users TO web_anon;

CREATE ROLE authenticator NOINHERIT LOGIN PASSWORD 'pwd here';
GRANT web_anon TO authenticator;

CREATE ROLE todo_user NOLOGIN;
GRANT todo_user TO authenticator;

GRANT USAGE ON schema api To todo_user;
GRANT ALL ON api.users TO todo_user;
I also use a python library for postgrest
this one
So this is a function I have to interact with postgrest
class UserManager:
    """This is the class that deals with events
    revolving around StockUsers in the database"""

    def __init__(self):
        self.host = "http://localhost:3000/"

    async def create_user(self, first_name, last_name, username, email, password):
        """Adds a user to the StockTools database"""
        print('receiver end')
        async with postgrest.Client(self.host, default_headers={"role": "todo_user"}) as client:
            try:
                print('inside try block')
                user_insert = await client.insert("users", {'last_name': last_name, 'first_name': first_name,
                                                            'user_name': username, 'email': email},
                                                  returning='representation')
                print('user insert complete')
                print(user_insert)
                await client.insert('passwords', {'encrypted_password': hashlib.sha3_512(password).hexdigest(),
                                                  'ref_user_id': user_insert})
                print('inserted passwords')
            except Exception as err:
                print(err)
                raise CannotManageUserData(err)
        print('user created')
So In the default_headers parameter of postgrest.client I have defined the todo_user role
So, it should have access to insert into the database right?
well, when I try to run the script I get this error:
401, message='permission denied for table users', url=URL('http://localhost:3000/users')
Aryan Iyappan
@PsychicSimp
why? Please help me
52 replies
thanks
Aryan Iyappan
@PsychicSimp
@chsanch are u there?
Aryan Iyappan
@PsychicSimp
hi
Aryan Iyappan
@PsychicSimp
So I followed everythin correctly upto tutorial 1 step 3
but after that I get this error
doing the same request given in the tutorial
C:\Users\iyapp>curl http://localhost:3000/todos -X POST ^
More?      -H "Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoidG9kb191c2VyIn0.nMv9RT-HXsUmQLz1fv91APpIvRobaoGiK4QJDwKo9hw"   ^
More?      -H "Content-Type: application/json" ^
More?      -d "{\"task\": \"learn how to auth\"}"
{"hint":null,"details":null,"code":"42501","message":"permission denied for table todos"}
Why? pls help me
I have everything correct
this is my conf file
db-uri = "postgres://authenticator:mysecretpassword@localhost/test"
db-schema = "api"
db-anon-role = "web_anon"
jwt-secret = "testtttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttsecret"
Ruslan Talpa
@ruslantalpa
the authorization header line is wrong
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoidG9kb191c2VyIn0.nMv9RT-HXsUmQLz1fv91APpIvRobaoGiK4QJDwKo9hw"
Aryan Iyappan
@PsychicSimp
what
Ruslan Talpa
@ruslantalpa
Bearer <-
Aryan Iyappan
@PsychicSimp
how to fix it
so am using windows
how can i set a variable for it
waIT OMG IT ACTUALLY WORKED
THANKS
RUSLAN UR PRO
MAN THANKS
Ruslan Talpa
@ruslantalpa
:+1: