- Clone the repo:
git clone [email protected]:Ujjawal-K-Panchal/pysecuresql.git
- Create a Virtual Environment: (Optional but Recommended).
pip install virtualenv
.python -m venv <any-name>
.- Linux, Mac:
source <any-name>/bin/activate
. Windows:<any-name>\Scripts\activate
.
- Install the repo:
pip install ./pysecuresql
from ssql.connector import Connection
Connection(creds = (user, password, host, db)) #credentials for connecting to mysql server.
#sample 1. With Dictionary and Named Parameters.
user = connection.query("SELECT * FROM Mytable WHERE Name = %(username)s;", {"username": "XYZ"})
#sample 2. With List.
user = connection.query("SELECT * FROM Mytable WHERE Name = %s;", ["XYZ",])
#sample 3. With Tuple.
user = connection.query("SELECT * FROM Mytable WHERE Name = %s;", ("XYZ",))