Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pymysql as mariadb
- class MariaDB():
- """
- connects to database and sends/recieves sql statements
- """
- __connection = ""
- __cursor = ""
- __connected = False
- def __init__(
- self,
- database,
- user,
- password,
- host="localhost",
- port=3306,
- ):
- """
- [constructor]
- Connect to database
- database [string] database you want to connect to
- user [string] username
- password [string] password
- host [string] remote system to connect to
- (default: localhost)
- port [int] port number to connect to
- (default: 3306)
- """
- try:
- self.__connection = mariadb.connect(
- host=host,
- user=user,
- password=password,
- database=database,
- )
- self.__cursor = self.__connection.cursor()
- self.__connected = True
- except Exception as exception:
- print(exception)
- quit()
Add Comment
Please, Sign In to add comment