Package: pyoomysql
Py-OO-MySQLPython Object-Orinted MySQL interface.This allows to interact ith MySQL/MariaDB databases easily by constructing objects.Table of ContentsRequirementsClasses / ObjectsFunctionsSamples1. RequirementsThe MySQLLib package is developed fully in Python3 and is not compatible with Python 2.X at all. Please use Python 3.6 or later to ensure the best compatibility.
This package uses mysql-connector-python as backend. Make sure you have it installed by issuing the following command:pip install mysql-connector-python2. ClassesDatabaseThe database class represents a simple pairhostname:portand holds connection status and other useful information about the Database itself and the connection, when the last is established.Attributesauth_pluginAuthentication plugin support.connectionExisting connection object (from mysql.connector.connection) or None if there is no connection.hostnameHostname/IP address used to connect to.passwordPassword used for connecting to the database.portPort used to connect to the database. Defaults to 3306schemaAs in the default schema used for connecting to the databaseusernameUsername set for the connection.versionShort version numberfull_versionFull version and revisionMethods__init__(hostname, port=3306, schema, log_level)Constructor that will set hsotname, port and default schema along with the standard log_level INFO (as in the standard library logging.INFO)connect(username: string, password: string, [schema]: string, [auth_plugin]: string)Connects to the host:port using the provided username and password. The schema defaults to "information_schema"disconnectCloses the current connection if anyexecute(command: string)Executes a command in the database provided that there's a connection established.flush_privilegesFlushes privileges after  granting/revokingget_schemaReturns a dictionary with information about particular schemaget_schemasReturns a dictionary with information about all the schemas found in the databaseget_user_by_nameReturns user/host information for a given username, it might be more than oneget_user_by_name_hostReturns exactly one user/host information for a given usernameget_versionReturns the MySQL versionis_connectedReturns True if there's a connection established or False otherwise.load_schemasLoads schemas to the databasreconnectReconnects to the database in case of lost connection with same username and passwordSchemaThe schema class represents a schema within a database, thus it requires a database object to be passed to it at creation time.AttributescharsetReturns the character set for the schemacollationReturns collation for the schemadatabaseReturns hostname:port information about the database where the schema residesnameReturns the name of the schematablesReturns a list with the names of the tables in the schemaMethodscompareAllows the comparison of 2 schema objectsget_tableReturns information about a particular tableget_tablesReturns a list of the tables found in the schemaload_tablesLoads the tables to the schema attributeTableThe Table class represents a particular table within a schema within a database.AttributesdatabaseDatabase whrre the table residesfqnFully qualified name of the table in the form {schema_name}.{table_name}nameName of the tableschemaSchema where the table residesMethodscompare_dataAllows to compare row-per-row the contents of the table with another onedeleteDeletes rows from a table based on filtersget_columnsReturns a list with the names of the columns in the  tableget_insert_statementReturns the normal SQL insert statement for the tableget_rowcountReturns the number of rows in the tableinsertInserts data in the tabletruncateTruncates the table, removing all dataupdateUpdate rows in the Table based on some filtersUserThe User class represents a User within the databaseAttributesexistsBoolean showing if the user exists or notgrantsList of privileges that the user hashostHost authorized to connect fromrolesList of roles granted to the userusernameThis is self explanatoryMethodscreateCreate the user if it doesn't exist in the databasedropDrops the user if it exists in the databaseget_grantsUnder developmentupdateUpdates the user if it exists in the database3. FunctionsUtil: SQL4. Samples# Import the package
import pyoomysql

# Create Database object
mydb = pyoomysql.Datbase(
    hostname = "example.com",
    port = 3306
)

# Connect
mydb.connect(
    username="someuser",
    password="super_secret_password"
)

# Create a schema object
myschema = pyoomysql.Schema(
    database = mydb,
    name = "some_schema"
)

# Create Table object
mytable = pyoomysql.Table(
    schema = myschema,
    name = "some_table"
)

# Create User object
myuser = pyoomysql.User(
    name = "some_nice_username",
    host = "% or host to connect from",
    password = "very_long_and_strong_password"
)

# Create the user in the database
myuser.create()