Skip to content

Commit

Permalink
Merge pull request #76 from dr-rodriguez/master
Browse files Browse the repository at this point in the history
Fix for unicode characters when saving tables
  • Loading branch information
dr-rodriguez committed Oct 13, 2016
2 parents e29ace3 + c7062d8 commit ccb4ef3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion astrodbkit/__init__.py
@@ -1,2 +1,2 @@
from pkg_resources import get_distribution
__version__ = '0.6.0'
__version__ = '0.6.1'
9 changes: 4 additions & 5 deletions astrodbkit/astrodb.py
Expand Up @@ -1373,13 +1373,12 @@ def save(self, directory='tabledata'):
tablepaths.append(tablepath)
with open(tablepath, 'w') as f:
for line in self.conn.iterdump():
if sys.version_info.major == 2:
# line = line.decode('utf-8')
line = line.encode('utf-8').decode('utf-8')

line = line.strip()
if line.startswith('INSERT INTO "{}"'.format(table)):
f.write('%s\n' % line.encode('ascii', 'ignore'))
if sys.version_info.major == 2:
f.write(u'{}\n'.format(line).encode('utf-8'))
else:
f.write(u'{}\n'.format(line))

print("Tables saved to directory {}/".format(directory))
print("""=======================================================================================
Expand Down

0 comments on commit ccb4ef3

Please sign in to comment.