Retrieve data from an sqlite3 db (returns all rows, be careful!) CLI Example: .. code-block:: bash salt '*' sqlite3.fetch /root/test.db 'SELECT * FROM test;'
(db=None, sql=None)
| 77 | |
| 78 | |
| 79 | def fetch(db=None, sql=None): |
| 80 | """ |
| 81 | Retrieve data from an sqlite3 db (returns all rows, be careful!) |
| 82 | |
| 83 | CLI Example: |
| 84 | |
| 85 | .. code-block:: bash |
| 86 | |
| 87 | salt '*' sqlite3.fetch /root/test.db 'SELECT * FROM test;' |
| 88 | """ |
| 89 | cur = _connect(db) |
| 90 | |
| 91 | if not cur: |
| 92 | return False |
| 93 | |
| 94 | cur.execute(sql) |
| 95 | rows = cur.fetchall() |
| 96 | return rows |
| 97 | |
| 98 | |
| 99 | def tables(db=None): |