added sql stuff

This commit is contained in:
2022-11-25 12:55:49 +01:00
parent aea7c693d6
commit 0c233cdce8
11 changed files with 365 additions and 0 deletions

28
Freitag/db_con.py Normal file
View File

@@ -0,0 +1,28 @@
#! /usr/bin/env python3
#
#Benötigt python3-pymysql
# mysql -h notebook14 -u python -pvilla inventory
import sys
import pymysql
from utilities import hide_exception
def db_connect(credentials: dict):
connection = pymysql.connect(**credentials)
return connection
# Passwort aus Konfigiruationsdaten lesen
credentials = dict(
host = 'notebook14',
user = 'python',
password = 'villa',
database = 'inventory'
)
#Connection
def main():
db = db_connect(credentials)
db.close()
hide_exception(main)