import json

with open('users.json') as f:
    j = json.loads(f.read())

with open('users.sql', 'w') as f:
    f.write('INSERT INTO `users` (type, email, password, name, username, location, bio, confirmation_token, password_reset_token, archived) VALUES (0, \'admin\', \'8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918\', \'Administrator\', \'admin\', \'Admin location\', \'Admin bio\', NULL, NULL, false);\n')
    f.write('INSERT INTO `users` (type, email, password, name, username, location, bio, confirmation_token, password_reset_token, archived) VALUES (1, \'seller\', \'a4279eae47aaa7417da62434795a011ccb0ec870f7f56646d181b5500a892a9a\', \'Seller\', \'seller\', \'Seller location\', \'Seller bio\', NULL, NULL, false);\n')
    f.write('INSERT INTO `users` (type, email, password, name, username, location, bio, confirmation_token, password_reset_token, archived) VALUES (1, \'seller1\', \'a4279eae47aaa7417da62434795a011ccb0ec870f7f56646d181b5500a892a9a\', \'Seller 1\', \'seller1\', \'Seller 1 location\', \'Seller 1 bio\', NULL, NULL, false);\n')
    f.write('INSERT INTO `users` (type, email, password, name, username, location, bio, confirmation_token, password_reset_token, archived) VALUES (2, \'buyer\', \'6dbd0f28d0d97656768b7b4ed96255e67fd11740a44b1c4b575191b06e9e3a35\', \'Buyer\', \'buyer\', \'Buyer location\', \'Buyer bio\', NULL, NULL, false);\n')
    for i in j:
        # SHA2('asd', 256) = '688787d8ff144c502c7f5cffaafe2cc588d86079f9de88304c26b0cb99ce91c6'
        f.write('INSERT INTO `users` (type, email, password, name, username, location, bio, confirmation_token, password_reset_token, archived) VALUES (1, \'{}\', \'688787d8ff144c502c7f5cffaafe2cc588d86079f9de88304c26b0cb99ce91c6\', \'{}\', \'{}\', \'{}\', \'Hello, world!\', NULL, NULL, false);\n'.format(i['email'], i['name'], i['username'], i['location']))
