Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7951635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:37:11+00:00 2026-06-04T02:37:11+00:00

I often manually pull in production data into my test database so I can

  • 0

I often manually pull in production data into my test database so I can test new code on realistic data, as well as test upgrade scenarios or repro data specific bugs. To do this, I’ve setup a VIEW for each production table in my test database. These views look something like this:

CREATE VIEW ProdLink.Users AS
   select * from dblink(
      'hostaddr=123.123.123.123 dbname=ProductionDB user=ROUser password=secret',
      'select * from users') as t1(userid uuid, email varchar(50), alias varchar(50), fullname varchar(50), password varchar(100));

Now, on my production database I can run:

SELECT * FROM ProdLink.Users;

And see all users on my production database. I can then do things like:

INSERT INTO Users SELECT * FROM ProdLink.Users L WHERE NOT EXISTS (select 1 from Users where Users.UserId = L.UserId);

Allowing me to pull in every user from production that doesn’t already exist in test.

I have about 30 of these views to proxy the production data, however I find it somewhat hacky to have to hardcode in the production database connection info into each view.

My Question: Is there a good way to avoid hardcoding, or at least duplicating this connection info on each view? Can I use database level variables, environment variables, or anything else instead?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T02:37:13+00:00Added an answer on June 4, 2026 at 2:37 am

    To avoid duplication you can store the connection strings in a table:

    CREATE VIEW ProdLink.Users AS
        select * from dblink(
            (select conn_string from conn_string where conn = 'that_one'),
            'select * from users'
        ) as t1 (
            userid uuid, 
            email varchar(50), 
            alias varchar(50), 
            fullname varchar(50), 
            password varchar(100)
        );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I write .xml files in Eclipse, I often have to manually indent code.
I often accidently step into code that I'm not interested in while debugging in
Often I find myself coming across code like this: try { StreamWriter strw =
Often, I am building an array by iterating through some data, e.g.: my_array =
When developing in WPF, it is often useful to manually create the main window
Does anyone else is annoyed by putting strings into double quotes manually ? If
I have some code that uses an Informix 11.5 database that I want to
When manually generating a JSON object or array, it's often easier to leave a
I often need to execute custom sql queries in django, and manually converting query
I often have at least 3 remote branches: master, staging and production. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.