# Path: plenario/database.py
# def create_database(bind: Engine, database: str) -> None:
# def drop_database(bind: Engine, database: str) -> None:
# def create_extension(bind: Engine, extension: str) -> None:
# def psql(path: str) -> None:
# def postgres_session_context():
# def redshift_session_context():


import json
from geoalchemy2 import Geometry
from sqlalchemy import BigInteger, Boolean, Column, DateTime, Float, ForeignKey, ForeignKeyConstraint, String, Table, \
    func as sqla_fn
from sqlalchemy.dialects.postgresql import DOUBLE_PRECISION, JSONB
from sqlalchemy.orm import relationship
from plenario.database import postgres_base, postgres_engine, postgres_session, redshift_base
            if network_name is None or node.sensor_network.lower() == network_name.lower():
                for sensor in node.sensors:
                    for prop in sensor.observed_properties.values():
                        features.append(prop.split('.')[0].lower())
        return list(set(features))

    @staticmethod
    def properties_of(feature):
        query = postgres_session.query(FeatureMeta.observed_properties).filter(
            FeatureMeta.name == feature)
        return [feature + '.' + prop['name'] for prop in query.first().observed_properties]

    def mirror(self):
        """Create feature tables in redshift for all the networks associated
        with this feature.
        """
        for network in self.networks:
            self._mirror(network.name)

    def _mirror(self, network_name: str):
        """Create a feature table in redshift for the specified network.
        """
        columns = []
        for feature in self.observed_properties:
            column_name = feature['name']
            column_type = database_types[feature['type'].upper()]
            columns.append(Column(column_name, column_type, default=None))

        redshift_table = Table(
            '{}__{}'.format(network_name, self.name),

# Path: plenario/database.py
# def create_database(bind: Engine, database: str) -> None:
# def drop_database(bind: Engine, database: str) -> None:
# def create_extension(bind: Engine, extension: str) -> None:
# def psql(path: str) -> None:
# def postgres_session_context():
# def redshift_session_context():


# Path: plenario/models/SensorNetwork.py
import json
from geoalchemy2 import Geometry
from sqlalchemy import BigInteger, Boolean, Column, DateTime, Float, ForeignKey, ForeignKeyConstraint, String, Table, \
    func as sqla_fn
from sqlalchemy.dialects.postgresql import DOUBLE_PRECISION, JSONB
from sqlalchemy.orm import relationship
from plenario.database import postgres_base, postgres_engine, postgres_session, redshift_base

            if network_name is None or node.sensor_network.lower() == network_name.lower():
                for sensor in node.sensors:
                    for prop in sensor.observed_properties.values():
                        features.append(prop.split('.')[0].lower())
        return list(set(features))

    @staticmethod
    def properties_of(feature):
        query = postgres_session.query(FeatureMeta.observed_properties).filter(
            FeatureMeta.name == feature)
        return [feature + '.' + prop['name'] for prop in query.first().observed_properties]

    def mirror(self):
        """Create feature tables in redshift for all the networks associated
        with this feature.
        """
        for network in self.networks:
            self._mirror(network.name)

    def _mirror(self, network_name: str):
        """Create a feature table in redshift for the specified network.
        """
        columns = []
        for feature in self.observed_properties:
            column_name = feature['name']
            column_type = database_types[feature['type'].upper()]
            columns.append(Column(column_name, column_type, default=None))

        redshift_table = Table(
            '{}__{}'.format(network_name, self.name),

            redshift_base.metadata,