Skip to content

Commit 5a5cc32

Browse files
author
Alex Toker
committed
Timescaledb: handle schemas
1 parent ba3df24 commit 5a5cc32

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

storey/timescaledb_target.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ def __init__(
112112
self._dsn = dsn
113113
self._pool = None # Connection pool will be created lazily during first use
114114
self._column_names = self._get_column_names()
115+
self._schema = None
116+
if "." in self._table:
117+
self._schema, self._table = self._table.split(".", 1)
115118

116119
def _init(self):
117120
"""Initialize the target (called synchronously).
@@ -193,7 +196,9 @@ async def _emit(self, batch, batch_key, batch_time, batch_events, last_event_tim
193196
async with self._pool.acquire() as conn:
194197
# Use PostgreSQL's COPY protocol for optimal performance
195198
# This is significantly faster than individual INSERT statements
196-
await conn.copy_records_to_table(self._table, records=records, columns=self._column_names)
199+
await conn.copy_records_to_table(
200+
self._table, schema_name=self._schema, records=records, columns=self._column_names
201+
)
197202

198203
async def _terminate(self):
199204
"""Terminate and cleanup resources.

0 commit comments

Comments
 (0)