added sql stuff
This commit is contained in:
28
Freitag/db_con.py
Normal file
28
Freitag/db_con.py
Normal 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)
|
||||
Reference in New Issue
Block a user