# 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/utils/helpers.py
# def get_size_in_degrees(meters, latitude):
#     earth_circumference = 40041000.0  # meters, average circumference
#     degrees_per_meter = 360.0 / earth_circumference
# 
#     degrees_at_equator = meters * degrees_per_meter
# 
#     latitude_correction = 1.0 / math.cos(latitude * (math.pi / 180.0))
# 
#     degrees_x = degrees_at_equator * latitude_correction
#     degrees_y = degrees_at_equator
# 
#     return degrees_x, degrees_y
# 
# def slugify(text: str, delimiter: str = '_') -> str:
#     return _slugify(text, separator=delimiter)


import json
import sqlalchemy as sa
from collections import namedtuple
from datetime import datetime
from hashlib import md5
from itertools import groupby
from operator import itemgetter
from flask_bcrypt import Bcrypt
from geoalchemy2 import Geometry
from shapely.geometry import shape
from sqlalchemy import Boolean, Column, Date, DateTime, String, Table, Text, func, select
from sqlalchemy.dialects.postgresql import ARRAY, JSONB
from sqlalchemy.exc import ProgrammingError
from plenario.database import postgres_base, postgres_session
from plenario.utils.helpers import get_size_in_degrees, slugify
    contributor_name = Column(String)
    contributor_organization = Column(String)
    contributor_email = Column(String)
    result_ids = Column(ARRAY(String))
    column_names = Column(JSONB)  # {'<COLUMN_NAME>': '<COLUMN_TYPE>'}

    def __init__(self, url, human_name, observed_date,
                 approved_status=False, update_freq='yearly',
                 latitude=None, longitude=None, location=None,
                 attribution=None, description=None,
                 column_names=None,
                 contributor_name=None, contributor_email=None,
                 contributor_organization=None, **kwargs):
        """
        :param url: url where CSV or Socrata dataset with this dataset resides
        :param human_name: Nicely formatted name to display to people
        :param business_key: Name of column with the dataset's unique ID
        :param observed_date: Name of column with the datset's timestamp
        :param approved_status: Has an admin signed off on this dataset?
        :param update_freq: one of ['daily', 'weekly', 'monthly', 'yearly']
        :param latitude: Name of col with latitude
        :param longitude: Name of col with longitude
        :param location: Name of col with location formatted as (lat, lon)
        :param attribution: Text describing who maintains the dataset
        :param description: Text describing the dataset.
        """
        def curried_slug(name):
            if name is None:
                return None
            else:

# 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/utils/helpers.py
# def get_size_in_degrees(meters, latitude):
#     earth_circumference = 40041000.0  # meters, average circumference
#     degrees_per_meter = 360.0 / earth_circumference
# 
#     degrees_at_equator = meters * degrees_per_meter
# 
#     latitude_correction = 1.0 / math.cos(latitude * (math.pi / 180.0))
# 
#     degrees_x = degrees_at_equator * latitude_correction
#     degrees_y = degrees_at_equator
# 
#     return degrees_x, degrees_y
# 
# def slugify(text: str, delimiter: str = '_') -> str:
#     return _slugify(text, separator=delimiter)


# Path: plenario/models/MetaTable.py
import json
import sqlalchemy as sa
from collections import namedtuple
from datetime import datetime
from hashlib import md5
from itertools import groupby
from operator import itemgetter
from flask_bcrypt import Bcrypt
from geoalchemy2 import Geometry
from shapely.geometry import shape
from sqlalchemy import Boolean, Column, Date, DateTime, String, Table, Text, func, select
from sqlalchemy.dialects.postgresql import ARRAY, JSONB
from sqlalchemy.exc import ProgrammingError
from plenario.database import postgres_base, postgres_session
from plenario.utils.helpers import get_size_in_degrees, slugify

    contributor_name = Column(String)
    contributor_organization = Column(String)
    contributor_email = Column(String)
    result_ids = Column(ARRAY(String))
    column_names = Column(JSONB)  # {'<COLUMN_NAME>': '<COLUMN_TYPE>'}

    def __init__(self, url, human_name, observed_date,
                 approved_status=False, update_freq='yearly',
                 latitude=None, longitude=None, location=None,
                 attribution=None, description=None,
                 column_names=None,
                 contributor_name=None, contributor_email=None,
                 contributor_organization=None, **kwargs):
        """
        :param url: url where CSV or Socrata dataset with this dataset resides
        :param human_name: Nicely formatted name to display to people
        :param business_key: Name of column with the dataset's unique ID
        :param observed_date: Name of column with the datset's timestamp
        :param approved_status: Has an admin signed off on this dataset?
        :param update_freq: one of ['daily', 'weekly', 'monthly', 'yearly']
        :param latitude: Name of col with latitude
        :param longitude: Name of col with longitude
        :param location: Name of col with location formatted as (lat, lon)
        :param attribution: Text describing who maintains the dataset
        :param description: Text describing the dataset.
        """
        def curried_slug(name):
            if name is None:
                return None
            else:

                return slugify(str(name), delimiter='_')