Skip to content

Commit f1374ba

Browse files
Update structure to pyproject.toml
1 parent 0ea518d commit f1374ba

10 files changed

+57
-64
lines changed

.gitattributes

-1
This file was deleted.

Dockerfile

+6-7
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@ RUN apt-get clean \
1818

1919
WORKDIR /app
2020

21-
# Copy requirements and install Python dependencies
22-
COPY ./requirements.txt ./
23-
RUN pip install --no-cache-dir -r requirements.txt
24-
25-
# Copy the package and tests
26-
COPY ./sqlconnect ./sqlconnect
21+
# Install SQLConnect package and dev dependencies
22+
COPY ./src ./src
2723
COPY ./tests ./tests
28-
24+
COPY pyproject.toml README.md ./
25+
RUN pip install pytest ruff build twine
26+
RUN python -m build
27+
RUN pip install dist/*.whl

pyproject.toml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "sqlconnect"
7+
version = "0.3.1"
8+
authors = [{ name = "Justin Frizzell" }]
9+
description = "Simplifies connections to SQL databases for data analysts. Populate DataFrames with the results of queries directly from .sql files."
10+
readme = "README.md"
11+
keywords = ["SQL", "database", "connection", "configuration"]
12+
license = { text = "MIT License" }
13+
classifiers = [
14+
"License :: OSI Approved :: MIT License",
15+
"Intended Audience :: Developers",
16+
"Topic :: Database",
17+
]
18+
19+
requires-python = ">=3.8"
20+
21+
dependencies = [
22+
"pandas>=2.0.0",
23+
"sqlalchemy>=2.0.0",
24+
"pyyaml>=6.0.0",
25+
"python-dotenv>=1.0.0",
26+
"pyodbc>=5.0.0",
27+
"psycopg2-binary>=2.0.0",
28+
"oracledb>=2.0.0",
29+
"PyMySQL>=1.0.0",
30+
]
31+
32+
[project.urls]
33+
Homepage = "https://github.com/JustinFrizzell/sqlconnect"
34+
Documentation = "https://sqlconnect.readthedocs.io/en/latest/"
35+
36+
[project.optional-dependencies]
37+
dev = ["pytest>=7.0.0", "ruff>=0.3.0", "build>1.0.0", "twine>=5.0.0"]

requirements-dev.txt

-11
This file was deleted.

requirements.txt

-202 Bytes
Binary file not shown.

setup.py

-33
This file was deleted.

sqlconnect/__init__.py

-1
This file was deleted.

src/sqlconnect/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .connector import Sqlconnector # noqa: F401

sqlconnect/config.py src/sqlconnect/config.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
This module provides functionality for loading and validating SQL database connection configurations,
33
used primarily by the Sqlconnector class for establishing database connections.
44
5-
The module includes functions to retrieve connection configurations from a YAML file and to construct a
6-
database connection URL. It supports dynamic configuration through file paths and dictionaries, and handles
5+
The module includes functions to retrieve connection configurations from a YAML file and to construct a
6+
database connection URL. It supports dynamic configuration through file paths and dictionaries, and handles
77
secure storage of sensitive details (e.g., usernames and passwords) through environment variables.
88
99
Functions:
1010
get_connection_config: Retrieves the configuration for a specified connection from a YAML file.
1111
get_db_url: Constructs and returns a database connection string from a given configuration dictionary.
1212
1313
Used By:
14-
- Sqlconnector: This class in a separate module utilises the functions provided here to manage database
14+
- Sqlconnector: This class in a separate module utilises the functions provided here to manage database
1515
connections and operations.
1616
1717
Dependencies:
@@ -26,12 +26,13 @@
2626
db_url = get_db_url(config)
2727
2828
Notes:
29-
- Configuration files should define connection parameters like 'sqlalchemy_driver', 'odbc_driver',
29+
- Configuration files should define connection parameters like 'sqlalchemy_driver', 'odbc_driver',
3030
'server', 'database', and optionally 'username', 'password'.
3131
- Usernames and passwords should be referenced as environment variables in the format '${ENV_VAR}'.
32-
- Attempts to load 'sqlconnect.env' files from the current directory or the user's home directory for environment
32+
- Attempts to load 'sqlconnect.env' files from the current directory or the user's home directory for environment
3333
variables.
3434
"""
35+
3536
import os
3637
from pathlib import Path
3738
import yaml

sqlconnect/connector.py src/sqlconnect/connector.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
2-
The Sqlconnector class in this module is designed to aid database interactions using SQLAlchemy.
3-
It includes methods for establishing database connections, executing SQL queries and commands,
4-
and retrieving query results as pandas DataFrames. The class can be configured using either a
2+
The Sqlconnector class in this module is designed to aid database interactions using SQLAlchemy.
3+
It includes methods for establishing database connections, executing SQL queries and commands,
4+
and retrieving query results as pandas DataFrames. The class can be configured using either a
55
configuration file (`sqlconnect.yaml`) or a dictionary.
66
77
Classes:
@@ -15,14 +15,15 @@
1515
1616
Example:
1717
>>> import sqlconnect as sc
18-
>>>
18+
>>>
1919
>>> connection = sc.Sqlconnector("My_Database")
20-
>>>
20+
>>>
2121
>>> df = connection.sql_to_df("path/to/sql_query.sql") # Assign results of a query to a DataFrame
22-
>>>
22+
>>>
2323
>>> print(df.describe()) # Explore the dataframe with Pandas
2424
2525
"""
26+
2627
from typing import Union, Generator
2728
from pathlib import Path
2829
import pandas as pd

0 commit comments

Comments
 (0)