I have developed an application using postgresql and it works well.
Now I need to create several instances of the same application but I have only one database. So I am thinking about using schemas, so that I can group each instance tables in a different schema.
Now, I wouldn't like to rewrite all my functions and script, thus I am wondering if I can just use some directive to instruct the database to operate on a specific schema. Just to try to make it clearer, do you know when in c++ you do
using namespace std;
so that you can use cout
instead of std::cout
? I would like to use someting similar if possible.
set schema 'schemaname';
and all unqualified table/view names will referenceschemaname
schema. See postgresql.org/docs/9.1/static/sql-set.html.set session schema 'name'
, according to docs "Specifies that the command takes effect for the current session. (This is the default if neither SESSION nor LOCAL appears.)". I can't tell you now if it works for psycopg - probably yes.