@@ -33,6 +33,7 @@ def map_type(duckdb_type: str) -> str:
3333
3434def start_server (
3535 layer : SemanticLayer ,
36+ host : str = "127.0.0.1" ,
3637 port : int = 5433 ,
3738 username : str | None = None ,
3839 password : str | None = None ,
@@ -41,6 +42,7 @@ def start_server(
4142
4243 Args:
4344 layer: Semantic layer instance
45+ host: Host/IP to bind to (use 0.0.0.0 for Docker)
4446 port: Port to listen on
4547 username: Username for authentication (optional)
4648 password: Password for authentication (optional)
@@ -52,7 +54,7 @@ def __init__(self, connection_id, executor):
5254 super ().__init__ (connection_id , executor , layer , username , password )
5355
5456 # Start server
55- server = riffq .RiffqServer (f"127.0.0.1 :{ port } " , connection_cls = BoundConnection )
57+ server = riffq .RiffqServer (f"{ host } :{ port } " , connection_cls = BoundConnection )
5658
5759 # Register catalog
5860 typer .echo ("Registering semantic layer catalog..." , err = True )
@@ -134,12 +136,13 @@ def __init__(self, connection_id, executor):
134136 server ._server .register_table ("sidemantic" , "semantic_layer" , "metrics" , metric_columns )
135137 typer .echo (" Registered table: semantic_layer.metrics" , err = True )
136138
137- typer .echo (f"\n Starting PostgreSQL-compatible server on 127.0.0.1 :{ port } " , err = True )
139+ typer .echo (f"\n Starting PostgreSQL-compatible server on { host } :{ port } " , err = True )
138140 if username :
139141 typer .echo (f"Authentication: username={ username } " , err = True )
140142 else :
141143 typer .echo ("Authentication: disabled (any username/password accepted)" , err = True )
142- typer .echo (f"\n Connect with: psql -h 127.0.0.1 -p { port } -U { username or 'any' } -d sidemantic\n " , err = True )
144+ connect_host = "localhost" if host == "0.0.0.0" else host
145+ typer .echo (f"\n Connect with: psql -h { connect_host } -p { port } -U { username or 'any' } -d sidemantic\n " , err = True )
143146
144147 # Disable catalog_emulation and handle catalog queries manually in our Python handler
145148 # This prevents riffq from intercepting queries with its DataFusion parser (which fails on multi-statement queries)
0 commit comments