Skip to content

Instantly share code, notes, and snippets.

@iffy
Created March 30, 2015 22:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iffy/e90d9078a96e6f4d9bba to your computer and use it in GitHub Desktop.
Save iffy/e90d9078a96e6f4d9bba to your computer and use it in GitHub Desktop.
app:
build: .
links:
- db
db:
image: mysql
environment:
- MYSQL_ROOT_PASSWORD=notsecret
- MYSQL_USER=foo
- MYSQL_PASSWORD=foo
- MYSQL_DATABASE=foo
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
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)
$ 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment