Firebase: How to read from external DB?


I have some data in PostgreSQL on another server that I need to read to include in my Firebase app, and then render charts. I only have the db connection string, there are no endpoints there to return that data.


I would restrict entering connection string to admin, using auth and roles on Firebase.

</li> <li>

Then I need a way for Firebase app to grab that data with SQL and show on client, which would render tables and charts.

</li> <li>

The user should never be able to see the connection strings, even in network traffic.

</li> </ul>

Is this doable and how?


I had a similar problem to solve and as a <strong>temporary solution</strong> I initialized app with firebase admin serviceAccount. Then listened for changes of firebase collection on my server and on new value received inserted\updated the values in PostgreSQL.

Initialize app as admin and listen for changes on firebase:

admin.initializeApp({ credential: admin.credential.cert(serviceAccount), databaseURL: 'https://yourfirebaseproject.firebaseio.com', }); const db = admin.database(); db.ref('User').on('value', async (snapshot) => { insertOrUpdate(User, 'users', snapshot.val()); });

Insert\update data into PostgreSQL:

const insertOrUpdate = (model, tableName, data) => { const firstData = data[0] ? data[0] : data; return model.knex().raw( knex(tableName).insert(data).toQuery() + ' ON CONFLICT ("id") DO UPDATE SET ' + Object.keys(firstData).map((field) => `${field}=EXCLUDED.${field}`).join(', ') ); };


Firebase has no "sync with PostgreSQL" API.

So either you app will need to do that (meaning that it has access to both the PostgreSQL an the Firebase Database) or you'll need to set up a server to do so.

Since you already ruled that the app can't know the PostgreSQL connection string, that only leaves doing this on a server (or some other place that the general users don't have access to).

Beyond that the scenario is incredibly broad. There are many, many ways to implement it.


  • Task queue for wp8?
  • best simplest code to move a UIImage View from point A to point B
  • Python + Tkinter Windows 7 taskbar progress
  • wxpython notebook inside boxsizer
  • Swift 3 and JSON – Updating the database by running a URL in the background
  • Pimcore where does code go
  • slide Wipe effects with ImageMagick tool and ffmpeg
  • Backing up data volume containers off machine
  • When using Shibboleth (v3) as SP , can I map the attribute value in attribute-map.xml?
  • Get Network Interface Names and Set All to DHCP Batch Script
  • JQuery and PHP validation problem?
  • Master makefile which runs make files in subdirectories
  • Can the use of C++11's 'auto' deteriorate performance or even break the code?
  • How to open a serial port with pyserial?
  • Qt fresh Gui application crashes on startup, faulting at QtCore4.dll
  • Salesforce consuming XML and display data in Visualforce report
  • iOS Today Extension created as .app rather than .appex
  • Parallelization via JDBC - Pyspark - How does parallelization work using JDBC?
  • Firebase: Create/Update multiple child nodes atomically
  • Unable to run testNG tests from maven
  • JQuery Mobile Ajax Navigation in Single-Page Template
  • Javascript inside HTML import not affecting imported HTML
  • How to add html image in to velocity template file to send email?
  • Debugging php script timeout?
  • Splitting ReportLab table across PDF page (side by side)?
  • Facebook Error (#200) The user hasn't authorized the application to perform this action (PHP)
  • How to use Typescript with libraries like Ampersand.js that parse configs to build prototypes
  • How to load dynamic images in custom ListView
  • Set SelectedIndex of ListView in FlipView_SelectionChanged event
  • What is the difference between dynamically creating a script tag and statically embed a script tag?
  • How to merge objects within array based on attribute
  • concise way of flattening multiindex columns
  • How to call jQuery function in HTML returned by AJAX
  • Send array to next viewcontroller iOs xcode [duplicate]
  • How to encrypt Connectionstring written in web.config from codebehind?
  • Computing the discrete fourier transform of audio data with FFTW
  • Using Service Component Runtime
  • How to mutate multiple variables without repeating codes?
  • convert json to excel in java
  • Create/delete users from text file using Bash script