Database Connection Creation with pymysql

  • Share this:

Code introduction


This function uses the pymysql library to create a database connection, accepting the host address and port as parameters.


Technology Stack : pymysql

Code Type : Function

Code Difficulty : Intermediate


                
                    
def get_random_connection(host, port):
    import pymysql
    connection = pymysql.connect(host=host, port=port)
    return connection                
              
Tags: