Skip to content

Instantly share code, notes, and snippets.

@linxuedong
linxuedong / gist:72eed71281caedb83123efe3e267c266
Created January 8, 2019 02:58
flask-sqlalchemy 数据库 relationship #flask #SQLAlchemy
http://flask-sqlalchemy.pocoo.org/2.3/models/#one-to-many-relationships
@linxuedong
linxuedong / heroku_postgres.md
Last active December 25, 2018 02:56
Heroku postgres

APP_NAME: heroku app name 例如:sushi
DATABASE_URL: global name for postgres add-on 例如:postgresql-curly-xxx

Creating a backup

创建备份
heroku pg:backups:capture --app APP_NAME

Scheduling backups

@linxuedong
linxuedong / postgresql.md
Created September 19, 2018 07:05
#postgres

查询导出 CSV 文件

\copy (select * from t1) To 'filename.csv' With CSV HEADER

OR

COPY (select * from t1) TO '/var/lib/postgresql/f.csv' WITH CSV HEADER;

REF

@linxuedong
linxuedong / restart_postgresql.md
Created August 18, 2018 16:21
restart postgresql #postgres
@linxuedong
linxuedong / test.md
Created August 13, 2018 03:28
Test to check the response of an API in Flask #flask #test
from flask import jsonify
@app.route("/hello")
def hello(): 
    return jsonify({'hello': 'world'})

Test:

import json
class MyTestCase(unittest.TestCase):
@linxuedong
linxuedong / alembic.md
Created July 24, 2018 13:16
alembic #shell

Alembic:

alembic revision --autogenerate -m "init"

相当于 Django 中:

python manage.py makemigrations

Alembic:

@linxuedong
linxuedong / gzip.md
Created July 23, 2018 05:18
压缩文件 #shell

压缩文件

gzip filename

# eg
gzip test.sql

解压文件