Permalink
Browse files

fix all the minor troubles

  • Loading branch information...
1 parent 7492a12 commit f10a0d158345bcf8a5b3546eb82b335b46d72ffb @piranha committed Aug 20, 2013
Showing with 9 additions and 4 deletions.
  1. +1 −1 nomad/engine/sqla.py
  2. +4 −3 nomad/repo.py
  3. +4 −0 nomad/utils.py
View
@@ -8,7 +8,7 @@ def connect(self):
return create_engine(self.url)
def prepare(self, statement):
- if self.connection.name in ('mysql', 'pgsql'):
+ if self.connection.name in ('mysql', 'pgsql', 'postgresql'):
return statement.replace('?', '%s')
return statement
View
@@ -4,7 +4,8 @@
from subprocess import call
from functools import wraps
-from nomad.utils import cachedproperty, geturl, NomadError, NomadIniNotFound
+from nomad.utils import (cachedproperty, geturl, NomadError, NomadIniNotFound,
+ clean_sql)
def tx(getrepo):
@@ -140,7 +141,7 @@ def apply(self):
path = op.join(self.path, fn)
if fn.endswith('.sql'):
with open(path) as f:
- self.repo.engine.query(f.read())
+ self.repo.engine.query(clean_sql(f.read()))
print ' sql migration applied: %s' % fn
elif os.access(path, os.X_OK):
call(path)
@@ -150,5 +151,5 @@ def apply(self):
self.repo.engine.query('INSERT INTO %s (name, date) VALUES (?, ?)'
% self.repo.conf['nomad']['table'],
- self.name, datetime.now())
+ self.name, str(datetime.now()))
self.applied = True
View
@@ -79,6 +79,10 @@ def loadpath(path):
return imp.load_source(modname, path)
+def clean_sql(sql):
+ return '\n'.join(x for x in sql.split('\n')
+ if not x.strip().startswith('--'))
+
### URL retrievers
def get_python(path):

0 comments on commit f10a0d1

Please sign in to comment.