Created
March 30, 2015 22:40
-
-
Save iffy/e90d9078a96e6f4d9bba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker-compose |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app: | |
build: . | |
links: | |
- db | |
db: | |
image: mysql | |
environment: | |
- MYSQL_ROOT_PASSWORD=notsecret | |
- MYSQL_USER=foo | |
- MYSQL_PASSWORD=foo | |
- MYSQL_DATABASE=foo | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu | |
RUN apt-get update -y | |
RUN apt-get install -y python-dev | |
RUN apt-get install -y libmysqlclient-dev | |
RUN apt-get install -y python-pip && pip install -U pip | |
COPY requirements.txt requirements.txt | |
RUN pip install -r requirements.txt | |
ADD . /code | |
WORKDIR /code | |
CMD python main.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import MySQLdb | |
db = MySQLdb.connect(host='db', user='foo', passwd='foo', db='foo') | |
db.query(''' | |
CREATE TEMPORARY TABLE foo ( | |
b BLOB, | |
tb TEXT CHARACTER SET latin1 COLLATE latin1_bin, | |
t TEXT | |
)''') | |
print 'hello' | |
c = db.cursor() | |
sample = '\x00\x01' | |
c.execute("INSERT INTO foo (b, tb, t) VALUES (%s, %s, %s)", (sample, sample, sample)) | |
print 'stored: %r' % (sample,) | |
c.execute("SELECT * FROM foo") | |
r = c.fetchall() | |
print repr(r) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ fig start db; sleep 10 | |
$ fig stop app && fig build app && fig up app | |
... | |
app_1 | hello | |
app_1 | stored: '\x00\x01' | |
app_1 | (('\x00\x01', '\x00\x01', '\x00\x01'),) | |
jwttest_app_1 exited with code 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MySQL-python |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment