Skip to content

Instantly share code, notes, and snippets.

View kevinlincg's full-sized avatar

KevinLin kevinlincg

  • Taiwan
View GitHub Profile
@kevinlincg
kevinlincg / mariadb.repo
Last active November 2, 2018 02:49
supervisord
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.2/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
#!/bin/bash
wget -qO- https://get.docker.com/ | sh
sudo usermod -aG docker $(whoami)
sudo systemctl enable docker.service
sudo systemctl start docker.service
sudo yum install -y epel-release
sudo yum install -y python-pip
sudo yum upgrade -y python*
sudo pip install docker-compose --force --upgrade
def get_or_create(session, model, **kwargs):
'''
Creates an object or returns the object if exists
credit to Kevin @ StackOverflow
from: http://stackoverflow.com/questions/2546207/does-sqlalchemy-have-an-equivalent-of-djangos-get-or-create
'''
instance = session.query(model).filter_by(**kwargs).first()
if instance:
return instance
else: