Code Monkey home page Code Monkey logo

autocredentials-mysql's Introduction

MySQL Auto-credentials configurator for Python

Automatically connect your Python program with your MySQL database by running this python script and entering your credentials in the asking output.

How to run:

Clone the project and copy the credent.py to your project folder.

Then install the mysql.connector library by creating a virtual environment through powershell in your project directory by the below commands:

  • For Windows:
python -m venv venv
venv/Scripts/activate.ps1
  • For Linux / macOS:
python3 -m venv venv
source venv/bin/activate

To install the library:

pip install mysql-connector-python

Then simply run the credent.py in the virtual environment which you created by:

  python credent.py

Follow all the steps the script says.

That's It! You have configured the MySQL credentials.

Now move to your main python program and enter the following lines to connect it to the mysql credentials which you entered before.

import os
import sys

sys.path.append(os.path.join(os.path.dirname(__file__), 'mysql_cred_data'))        
from cred import connect_to_database

connection = connect_to_database()

To connect the cursor, you can:

mycursor = connection.cursor()

Now You have successfully connected your python program to your MySQL Database!

Further Configurations

Now you should see a new directory in your project directory called mysql-cred-data. This is where all your MySQL credentials are stored. You can edit the cred.py file or any config files according to your needs. Or you can simply run the cred.py once again to re-configure your connection.

Author

  • Sidharth Prabhu

autocredentials-mysql's People

Contributors

sidharth-prabhu avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.