Basic Python 3 class for connecting to Databases
I recommend using this as a super class for a custom class, as shown in the quickstart, but can be used without.
This is something I built for personal (local) projects. I'll expand this repository when I need a new type of database connection for a project. By doing it this way, I have a nice all-in one package for all my different database connections. The goal is to keep the code and package as small and lightweigth as possible.
These databases are tested and working with the current build.
- AzureSQL
- SQLServer Express
These databases should work, but are not (fully) tested
- MySQL
- SQLite
- port: 1433
- driver: ODBC Driver 17 for SQL Server
from SimpleSQLConnector.Connectors import SQLConnector
class CustomSQLConnector(SQLConnector):
def __init__(self,
password,
server="my-server-endpoint",
database="my-database-name",
username="my-db-username",
):
super().__init__(username, password, server, database)
db = CustomSQLConnector(password="my-db-password")
# Get a user by his/her id
id = "00000000-1234-5678-abcd-000000000001" # example uuid4
result = db.get_item_by_id("User", id)
print(result)
- SQL Connector
- Database Cache
- MongoDB Connector