Replies: 1 comment 8 replies
-
You can specify the You are probably better off making sure your queries use properly qualified schemas: DB.from{schema[:database][:table]}.sql
# SELECT * FROM schema.database.table If you want to get fancy, it is possible to get the schema delayed until runtime: ds = DB.from(Sequel.delay{Sequel[Thread.current[:sequel_schema] || :default_schema][:database][:table]})
ds.sql
# SELECT * FROM default_schema.database.table
Thread.current[:sequel_schema] = :foo
ds.sql
# SELECT * FROM foo.database.table |
Beta Was this translation helpful? Give feedback.
8 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello!,
I would like to know if there is a way to set a default postgres schema per connection after the database connection has been declared
Let me explain a little bit how I'm doing things right now,
I have an AWS Lambda function that processes some reports for an enterprise database, i decided to use Sequel for it's
speed, this database uses multiple schemas for "tenant" database encapsulation.
Each time a request is processed i know which schema is needed, but as i know only this information at "execution" time
i can't declare the de database connection as suggested on the documentation (DB = Sequel.connect...)
At the moment what i do is declare a global variable named $db but i understand this not a good programming practice.
Here is hoping someone can help me shedding some light on a path to take with this.
Thanks for reading, and sorry for my english, and if my question is no clear enough.
Beta Was this translation helpful? Give feedback.
All reactions