Skip to content

Commit 7a2dbfe

Browse files
committed
Add Sphinx documentation
1 parent f039e42 commit 7a2dbfe

File tree

17 files changed

+219
-111
lines changed

17 files changed

+219
-111
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33

44
# Ignore virtual environment
55
.venv/
6+
7+
docs/build/
8+

README.md

Lines changed: 0 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -26,102 +26,7 @@ This makes it ideal for projects involving multiple interdependent queries, such
2626

2727
## Usage
2828

29-
### `create_sqlite_db` function:
3029

31-
```python
32-
# Import necessary modules
33-
import pandas as pd
34-
from sqlite_manager import create_sqlite_db
35-
36-
# Example DataFrame
37-
data = {
38-
"id": [1, 2, 3],
39-
"name": ["Alice", "Bob", "Charlie"],
40-
"age": [25, 30, 35]
41-
}
42-
df = pd.DataFrame(data)
43-
44-
# Path to schema file (must contain the table definition)
45-
schema_file = "db_schema.sql"
46-
47-
# Example schema (contents of db_schema.sql)
48-
# CREATE TABLE ExampleTable (
49-
# id INTEGER PRIMARY KEY,
50-
# name TEXT,
51-
# age INTEGER
52-
# );
53-
54-
# Path to SQLite database file
55-
db_file = "example_database.db"
56-
57-
# Create SQLite database from the DataFrame
58-
create_sqlite_db(
59-
df,
60-
schema_file,
61-
db_file
62-
)
63-
64-
# Verify: The database is created, and data is inserted into the ExampleTable.
65-
print(f"Database '{db_file}' created successfully with data from the DataFrame.")
66-
```
67-
68-
### `run_sql_queries` function:
69-
70-
```python
71-
from sqlite_manager import run_sql_queries
72-
73-
query_dir = "sql_queries" # Directory containing SQL files
74-
db_file = "data/online_retail.db" # SQLite database file
75-
output_dir = "output" # Directory to store query results
76-
77-
# Run all queries, skipping those with existing outputs
78-
run_sql_queries (
79-
query_dir,
80-
db_file,
81-
output_dir
82-
)
83-
84-
# Rerun all queries regardless of existing outputs
85-
run_sql_queries (
86-
query_dir,
87-
db_file,
88-
output_dir,
89-
rerun_all=True
90-
)
91-
92-
# Rerun specific queries
93-
run_sql_queries (
94-
query_dir,
95-
db_file,
96-
output_dir,
97-
rerun_queries=["query1.sql", "query2.sql"]
98-
)
99-
```
100-
101-
### Directory Layouts
102-
103-
##### Input Directory (SQL Queries):
104-
```text
105-
sql_queries/
106-
├── stage1/
107-
│ ├── query1.sql
108-
│ ├── query2.sql
109-
├── stage2/
110-
│ ├── query3.sql
111-
│ └── query4.sql
112-
113-
# Output Directory (Query Results):
114-
output/
115-
├── stage1/
116-
│ ├── query1.csv
117-
│ ├── query2.csv
118-
├── stage2/
119-
│ ├── query3.csv
120-
│ └── query4.csv
121-
```
122-
123-
The `run_sql_queries` mirrors the structure of the input directory for outputs,
124-
ensuring a clean and organized workflow.
12530

12631
## Installation
12732

@@ -130,8 +35,3 @@ Install directly from GitHub:
13035
```bash
13136
pip install git+https://github.com/Thomas-Rauter/[email protected]
13237
```
133-
134-
## When facing problems
135-
136-
For any issues or feature requests, please open an issue on the [GitHub
137-
repository](https://github.com/Thomas-Rauter/sqlite_manager).

__pycache__/setup.cpython-312.pyc

1.33 KB
Binary file not shown.

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = source
9+
BUILDDIR = build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/make.bat

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=source
11+
set BUILDDIR=build
12+
13+
%SPHINXBUILD% >NUL 2>NUL
14+
if errorlevel 9009 (
15+
echo.
16+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
17+
echo.installed, then set the SPHINXBUILD environment variable to point
18+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
19+
echo.may add the Sphinx directory to PATH.
20+
echo.
21+
echo.If you don't have Sphinx installed, grab it from
22+
echo.https://www.sphinx-doc.org/
23+
exit /b 1
24+
)
25+
26+
if "%1" == "" goto help
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd

docs/source/conf.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import os
2+
import sys
3+
sys.path.insert(0, os.path.abspath('../../'))
4+
5+
6+
# Configuration file for the Sphinx documentation builder.
7+
#
8+
# For the full list of built-in configuration values, see the documentation:
9+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
10+
11+
# -- Project information -----------------------------------------------------
12+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
13+
14+
project = 'sqlite_manager'
15+
copyright = '2025, Thomas Rauter'
16+
author = 'Thomas Rauter'
17+
release = '0.1.0'
18+
19+
# -- General configuration ---------------------------------------------------
20+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
21+
22+
extensions = [
23+
'sphinx.ext.autodoc',
24+
'sphinx.ext.napoleon', # For NumPy/Google-style docstrings
25+
]
26+
27+
28+
templates_path = ['_templates']
29+
exclude_patterns = ['**/__init__.py']
30+
31+
32+
# -- Options for HTML output -------------------------------------------------
33+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
34+
35+
html_theme = "furo"
36+
html_theme_options = {
37+
"sidebar_hide_name": True, # Hide the project name in the sidebar
38+
}
39+
html_static_path = ['_static']

docs/source/functions.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Function Reference
2+
==================
3+
4+
.. autofunction:: sqlite_manager.create_sqlite_db
5+
.. autofunction:: sqlite_manager.run_sql_queries

docs/source/index.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Welcome to sqlite_manager's documentation!
2+
==========================================
3+
4+
sqlite_manager is a Python package that simplifies working with SQLite databases by automating tasks like creating databases and running SQL queries.
5+
6+
Contents
7+
--------
8+
9+
.. toctree::
10+
:maxdepth: 1
11+
12+
functions

setup.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
1+
import os
12
from setuptools import setup, find_packages
23

4+
# Ensure the README file is read from the correct directory
5+
this_directory = os.path.abspath(os.path.dirname(__file__))
6+
readme_path = os.path.join(this_directory, "README.md")
7+
8+
# Read the README file
9+
with open(readme_path, "r", encoding="utf-8") as f:
10+
long_description = f.read()
11+
312
setup(
413
name="sqlite_manager",
514
version="0.1.0",
615
description="A package for managing SQLite operations",
7-
long_description=open("README.md").read(),
16+
long_description=long_description,
817
long_description_content_type="text/markdown",
918
author="Thomas Rauter",
1019
author_email="[email protected]",

0 commit comments

Comments
 (0)