$ gpspipe -w # log to stdout
$ gpspipe -w -o abc.log # log to a file
To auto-log on startup, insert the following line to the file /etc/rc.local
:
import logging | |
import psycopg2 | |
from psycopg2.extras import RealDictCursor | |
from psycopg2.extensions import TRANSACTION_STATUS_UNKNOWN, TRANSACTION_STATUS_IDLE | |
from flask import g | |
import threading | |
import tenacity | |
import uuid | |
import pwd | |
import os |
version: '2' | |
services: | |
nginx: | |
image: nginx:alpine | |
restart: always | |
labels: | |
- "traefik.enable=true" | |
- 'traefik.frontend.rule=Host:www.website.com' | |
- "traefik.port=80" | |
volumes: |
#!/usr/bin/python3.6 | |
"""Sync PostgreSQL.""" | |
import psycopg2 | |
import sys | |
from psycopg2.extras import RealDictCursor, execute_values | |
""" | |
Usage: |
FROM python:3.6 | |
WORKDIR /app | |
ADD . /app | |
RUN pip install -r requirements.txt | |
RUN python setup.py build_ext --inplace | |
ENTRYPOINT ["python"] | |
CMD ["app.py"] |
#!/usr/bin/env/python | |
import psycopg2 | |
import os | |
from io import StringIO | |
import pandas as pd | |
# Get a database connection | |
dsn = os.environ.get('DB_DSN') # Use ENV vars: keep it secret, keep it safe | |
conn = psycopg2.connect(dsn) |
class FilterLowercase(BaseMongoEngineFilter): | |
def apply(self, query, value): | |
flt = {'%s__icontains' % self.column: value} | |
return query.filter(**flt) | |
def operation(self): | |
return gettext('contains') | |
class FilterLowercaseNot(BaseMongoEngineFilter): | |
def apply(self, query, value): |
import logging | |
import flask | |
app = flask.Flask(__name__) | |
@app.before_first_request | |
def setup_logging(): | |
if not app.debug: | |
# In production mode, add log handler to sys.stderr. | |
app.logger.addHandler(logging.StreamHandler()) |
The mini-tool has a CLI-Interface with the following options:
TODO
from flask import Flask | |
from flask.ext.sqlalchemy import SQLAlchemy | |
from flask.ext import admin, wtf | |
from flask.ext.admin.contrib import sqlamodel | |
app = Flask(__name__) | |
app.config['SECRET_KEY'] = '123456790' | |
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///test.sqlite' | |
db = SQLAlchemy(app) |