diff options
author | nil0j <nil.jimeno@estudiant.fjaverianas.com> | 2024-09-21 10:17:23 +0200 |
---|---|---|
committer | nil0j <nil.jimeno@estudiant.fjaverianas.com> | 2024-09-21 10:17:23 +0200 |
commit | faa13839f898c60ff5618be6e916ad2e60958468 (patch) | |
tree | d785b9e7c66d092c0e5fbc296382289f39fea501 /python/database.py |
init
Diffstat (limited to 'python/database.py')
-rw-r--r-- | python/database.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/python/database.py b/python/database.py new file mode 100644 index 0000000..5bc8b5f --- /dev/null +++ b/python/database.py @@ -0,0 +1,20 @@ +import mysql.connector + + +def getConnector(): + return mysql.connector.connect( + host="localhost", + user="root", + ) + + +def getCursor(connector): + return connector.cursor() + + +def runQuery(connector, query): + cursor = getCursor(connector) + cursor.execute(query) + result = cursor.fetchall() + cursor.close() + return result |