Update sql_writer.py

Works, maybe some problems with design