Created
August 22, 2016 04:26
-
-
Save glassresistor/99ae14fb5679564e1444db09b7a0daf0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 sqlalchemy import create_engine | |
| columns = ['flame_retardants',] | |
| engine = create_engine('postgresql:///your_user') | |
| def make_sql(column): | |
| #x21 = 'update tedx set %s=1 where %s="X"' % (column, column) | |
| #null20 = 'update tedx set %s=0 where %s is null"' % (column, column) | |
| sql = "alter table tedx alter %s type bool using case when %s='X' then TRUE else FALSE END;" % (column, column) | |
| engine.execute(sql) | |
| return engine.execute('select * from tedx;') | |
| sql_commands = list(map(make_sql, columns)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment