Is there a way to connect to the Spanner Emulator through a PGAdapter? I want to develop an application with PostgreSQL Dialect database.
connecting Spanner Emulator through PGAdapter
290 Views Asked by kanagaraj palanisamy At
2
There are 2 best solutions below
0

This is now supported.
Here's what Knut said on a github issue:
We've released support for PostgreSQL dialect databases in version 1.5.12 of the Emulator. Version 0.26.0 and higher of PGAdapter also supports connecting to the emulator.
This documentation page shows you how you can connect PGAdapter to the emulator.
EDIT 2024-01-17:
The Cloud Spanner Emulator supports the PostgreSQL dialect, and PGAdapter can also connect to the emulator. The simplest way to use PGAdapter with the emulator is to use the combined Docker image that contains both PGAdapter and the Emulator, and that has PGAdapter configured to connect to the emulator, and to automatically create any instance or database that is referenced in any incoming connection request. The latter makes it very easy to use for testing, as you don't have to worry about creating an instance and a database first.
Use it like this:
More information can be found here: https://github.com/GoogleCloudPlatform/pgadapter?tab=readme-ov-file#emulator
OLD ANSWER:
The Cloud Spanner emulator does not yet support the PostgreSQL dialect. PGAdapter can currently only be used with PostgreSQL-dialect Cloud Spanner databases, which means that even though you can connect to the emulator using PGAdapter, it would refuse to connect to any database on that emulator, because they use the GoogleSQL dialect. For the time being, the recommendation is to use either one of the following options for development instances: