@@ -27,31 +27,36 @@ implemented, or behave differently:
2727 ` user_name@database_name ` ignores ` user_name ` ; only ` database_name ` is used. Authentication is based on the * auth
2828 token*
2929 provided via the ` password ` field.
30- - ** SSL/TLS** : SSL is supported only for ` maincloud ` deployments (without mutual TLS). Other deployments (such as
31- ` standalone ` ) do not support SSL/TLS connections.
30+ - ** SSL/TLS** : SSL is supported only for ` SpacetimeDB Cloud ` deployments (without mutual TLS). Other deployments (such
31+ as ` SpacetimeDB Standalone ` ) do not support SSL/TLS connections.
3232- ** System Tables and Views** : SpacetimeDB provides its own system tables (e.g., ` SELECT * FROM st_table ` ) for
3333 introspection. These are not PostgreSQL-compatible, so tools relying on PostgreSQL system catalogs will not work.
3434- ** Port and Host** :
35- - In ` standalone ` deployments, specify the port with ` spacetime start --pg-port <port> ` . Without this flag,
36- connections using the PostgreSQL protocol are not enabled.
37- - In ` maincloud ` deployments, the port is always ` 5432 ` .
35+ - In ` SpacetimeDB Standalone ` deployments, specify the port with ` spacetime start --pg-port <port> ` . Without this
36+ flag, connections using the PostgreSQL protocol are not enabled.
37+ - In ` SpacetimeDB Cloud ` deployments, the port is always ` 5432 ` .
3838- ** Transactions** : User-defined transactions (` BEGIN TRANSACTION ` , ` COMMIT ` , etc.) are not supported. Each SQL
3939 statement executes in its own transaction context. Client libraries should disable automatic transaction handling.
40+ - ** Special Data Types** : Some SpacetimeDB data types map to PostgreSQL types as:
41+ - Simple enums are displayed as ` Enum ` .
42+ - Algebraic Data Types (ADTs) & records are displayed as ` JSON ` .
43+ - ` Duration ` is displayed as ` Interval ` .
44+ - ` Identity ` , ` ConnectionId ` , ` U8 ` , ` [U8] ` , ` Bytes ` & ` Hex ` is displayed as ` Bytea ` .
4045
4146## Connection Parameters
4247
4348To connect to SpacetimeDB using a PostgreSQL client, use the following parameters:
4449
4550- ** Host** :
46- - ` localhost ` for ` standalone ` or ` local ` deployments
47- - ` maincloud.spacetimedb.com ` for ` maincloud ` deployments
51+ - ` localhost ` for ` SpacetimeDB Standalone ` deployments
52+ - ` maincloud.spacetimedb.com ` for ` SpacetimeDB Cloud ` deployments
4853- ** Port** :
49- - ` 5432 ` for ` maincloud `
50- - The value passed with ` --pg-port ` for ` standalone `
54+ - ` 5432 ` for ` SpacetimeDB Cloud `
55+ - The value passed with ` --pg-port ` for ` SpacetimeDB Standalone `
5156- ** Database** : The target SpacetimeDB database
5257- ** User** : Any string (ignored by SpacetimeDB)
5358- ** Password** : The ` auth token `
54- - ** SSL Mode** : ` require ` (only for ` maincloud ` )
59+ - ** SSL Mode** : ` require ` (only for ` SpacetimeDB Cloud ` )
5560
5661### Auth Token
5762
@@ -83,39 +88,58 @@ eval "$(spacetime login show --token | python3 ~/token.py)"
8388
8489## Examples
8590
86- Assume you are using the ` quickstart-chat ` database created in
91+ In the following example, we assume you are using the ` quickstart-chat ` database created in
8792the [ Rust Module Quickstart] ( /docs/modules/rust/quickstart ) or [ C# Module Quickstart] ( /docs/modules/c-sharp/quickstart ) ,
8893and have set the ` auth token ` as shown above.
8994
9095### Using ` psql `
9196
92- Standalone or local deployment:
97+ SpacetimeDB Standalone deployment:
9398
9499``` bash
95100psql " host=localhost port=5432 user=any dbname=quickstart-chat"
96101```
97102
98- Maincloud deployment:
103+ SpacetimeDB Cloud deployment:
99104
100105``` bash
101106psql " host=maincloud.spacetimedb.com port=5432 user=any dbname=quickstart-chat sslmode=require"
102107```
103108
104109> ** Note** : Introspection commands such as ` \dt ` will not work, as SpacetimeDB does not support PostgreSQL schemas.
105110
111+ Now for example:
112+
113+ ``` psql
114+ quickstart=> select * from message;
115+ sender | sent | text
116+ --------------------------------------------------------------------+----------------------------------+-------
117+ \xc200da2d6ddb6c0beef0bbaafacffe5f0649c86b8d19411e3219066a6d0e5123 | 2025-09-29T22:29:14.271647+00:00 | hello
118+ (1 row)
119+
120+ quickstart=> update message set text = 'world';
121+ updated: 1, server: 1.72ms
122+
123+ quickstart=> select text from message;
124+ text
125+ -------
126+ world
127+ (1 row)
128+ ```
129+
106130### Using Python (` psycopg2 ` )
107131
108132``` python
109133import psycopg2
110134import os
111135
112136conn = psycopg2.connect(
113- host = " localhost" , # or "maincloud.spacetimedb.com" for maincloud
137+ host = " localhost" , # or "maincloud.spacetimedb.com" for SpacetimeDB Cloud
114138 port = 5432 ,
115139 dbname = " quickstart-chat" ,
116140 user = " any" ,
117141 password = os.getenv(" PGPASSWORD" ),
118- sslmode = " disable" # use "require" for maincloud
142+ sslmode = " disable" # use "require" for SpacetimeDB Cloud
119143)
120144conn.set_session(autocommit = True ) # disable transactions
121145
@@ -209,8 +233,9 @@ async fn main() -> Result<(), anyhow::Error> {
209233 let connector = MakeRustlsConnect :: new (config );
210234
211235 let (client , connection ) = tokio_postgres :: connect (
236+ // Note: use "maincloud.spacetimedb.com" and sslmode=require for SpacetimeDB Cloud
212237 & format! (
213- " host=localhost port=5432 user=any sslmode=require dbname=quickstart-chat password={password}"
238+ " host=localhost port=5432 user=any sslmode=disable dbname=quickstart-chat password={password}"
214239 ),
215240 connector ,
216241 ). await ? ;
0 commit comments