Skip to content

Instantly share code, notes, and snippets.

@glesica
Created November 11, 2011 19:20
Show Gist options
  • Save glesica/1358942 to your computer and use it in GitHub Desktop.
Save glesica/1358942 to your computer and use it in GitHub Desktop.
def post(self, computer_name):
computer = self._get_computer(computer_name)
data = json.loads(self.request.body)
for application in data['applications']:
result = self.database.query(
'''
INSERT INTO applications (
application_name,
application_vendor,
application_version
) SELECT
%s,
%s,
%s
FROM dual WHERE NOT EXISTS (
SELECT *
FROM applications
WHERE
application_name=%s AND
application_vendor=%s AND
application_version=%s
);
''',
application['name'],
application['vendor'],
application['version'],
application['name'],
application['vendor'],
application['version']
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment