testcontainers-python icon indicating copy to clipboard operation
testcontainers-python copied to clipboard

TimeScaleDb container

Open vikrambosevibrent opened this issue 4 years ago • 2 comments

TimeScaleDb Container not available. is that any plan to add that? Thanks

vikrambosevibrent avatar Dec 22 '20 05:12 vikrambosevibrent

Not planned at the moment, but PRs are welcome.

tillahoffmann avatar Dec 22 '20 10:12 tillahoffmann

sure.. Will do that..

vikrambosevibrent avatar Dec 22 '20 11:12 vikrambosevibrent

It wouldn't be necessary to create a separate module/client for a TimescaleDB container since TimescaleDB is just an extension on top of PostgreSQL (see here). Users of the TimescaleDB container can make use of PostgresDB container client.

Example:

timescaled_container = PostgresContainer('timescale/timescaledb:latest-pg12')

with timescaled_container as timescaled:
    e = sqlalchemy.create_engine(timescaled.get_connection_url())
    e.execute('''
        CREATE TABLE stocks_real_time (
          time TIMESTAMPTZ NOT NULL,
          symbol TEXT NOT NULL,
          price DOUBLE PRECISION NULL,
          day_volume INT NULL
        ); 
    ''')

    e.execute('''
        SELECT create_hypertable('stocks_real_time','time');
    ''')

pffijt avatar Nov 21 '22 20:11 pffijt

I think we can close this issue :)

pffijt avatar Nov 22 '22 19:11 pffijt