Mercurial > repos > shellac > sam_consensus_v3
comparison env/lib/python3.9/site-packages/galaxy/util/sqlite.py @ 0:4f3585e2f14b draft default tip
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author | shellac |
---|---|
date | Mon, 22 Mar 2021 18:12:50 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4f3585e2f14b |
---|---|
1 import re | |
2 import sqlite3 | |
3 | |
4 try: | |
5 import sqlparse | |
6 | |
7 def is_read_only_query(query): | |
8 statements = sqlparse.parse(query) | |
9 for statement in statements: | |
10 if statement.get_type() != "SELECT": | |
11 return False | |
12 return True | |
13 | |
14 except ImportError: | |
15 # Without sqlparse we use a very weak regex check | |
16 def is_read_only_query(query): | |
17 if re.match("select ", query, re.IGNORECASE): | |
18 if re.search("^([^\"]|\"[^\"]*\")*?;", query) or re.search("^([^\']|\'[^\']*\')*?;", query): | |
19 return False | |
20 else: | |
21 return True | |
22 return False | |
23 | |
24 | |
25 def connect(path): | |
26 connection = sqlite3.connect(path) | |
27 connection.row_factory = sqlite3.Row | |
28 return connection |