- title: Python SQL Exceptions
id: 19aefed0-ffd4-47dc-a7fc-f8b1425e84f9
description: Generic rule for SQL exceptions in Python according to PEP 249
author: Thomas Patzke
references:
- https://www.python.org/dev/peps/pep-0249/#exceptions
logsource:
category: application
product: python
service: null
detection:
exceptions:
- DataError
- IntegrityError
- ProgrammingError
- OperationalError
condition: exceptions
falsepositives:
- Application bugs
- Penetration testing
level: medium
In [ ]:
from elasticsearch import Elasticsearch
from elasticsearch_dsl import Search
import pandas as pd
In [ ]:
es = Elasticsearch(['http://helk-elasticsearch:9200'])
searchContext = Search(using=es, index='logs-*', doc_type='doc')
In [ ]:
s = searchContext.query('query_string', query='\*.keyword:(*DataError* OR *IntegrityError* OR *ProgrammingError* OR *OperationalError*)')
response = s.execute()
if response.success():
df = pd.DataFrame((d.to_dict() for d in s.scan()))
In [ ]:
df.head()