sqlitables 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,35 @@
1
+ name: Build PyPI Distribution
2
+
3
+ on:
4
+ workflow_call:
5
+ outputs:
6
+ distribution-name:
7
+ value: ${{ jobs.pypi-build.outputs.distribution-name }}
8
+ distribution-path:
9
+ value: ${{ jobs.pypi-build.outputs.distribution-path }}
10
+
11
+ jobs:
12
+ pypi-build:
13
+ runs-on: ubuntu-latest
14
+ permissions:
15
+ contents: read
16
+ env:
17
+ distribution-name: PyPI Distribution
18
+ distribution-path: dist/
19
+ outputs:
20
+ distribution-name: ${{ env.distribution-name }}
21
+ distribution-path: ${{ env.distribution-path }}
22
+ steps:
23
+ - uses: actions/checkout@v6
24
+ - uses: actions/setup-python@v6
25
+ with:
26
+ python-version: "${{ vars.PYTHON_VERSION }}"
27
+ - name: Build Distribution
28
+ run: |
29
+ python -m pip install build
30
+ python -m build
31
+ - name: Save Distribution
32
+ uses: actions/upload-artifact@v7
33
+ with:
34
+ name: ${{ env.distribution-name }}
35
+ path: ${{ env.distribution-path }}
@@ -0,0 +1,26 @@
1
+ name: Publish PyPI Distribution
2
+
3
+ on: workflow_dispatch
4
+ # push:
5
+ # tags:
6
+ # - "v*"
7
+
8
+ jobs:
9
+ pypi-build:
10
+ uses: ./.github/workflows/pypi-build.yml
11
+ pypi-upload:
12
+ runs-on: ubuntu-latest
13
+ needs: pypi-build
14
+ environment:
15
+ name: pypi
16
+ url: ${{ vars.URL }}
17
+ permissions:
18
+ id-token: write
19
+ steps:
20
+ - name: Download Distribution
21
+ uses: actions/download-artifact@v8
22
+ with:
23
+ name: ${{ needs.pypi-build.outputs.distribution-name }}
24
+ path: ${{ needs.pypi-build.outputs.distribution-path }}
25
+ - name: Upload Distribution to PyPI
26
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,25 @@
1
+ name: Test PyPI Distribution
2
+
3
+ on: workflow_dispatch
4
+
5
+ jobs:
6
+ pypi-build:
7
+ uses: ./.github/workflows/pypi-build.yml
8
+ pypi-upload:
9
+ runs-on: ubuntu-latest
10
+ needs: pypi-build
11
+ environment:
12
+ name: testpypi
13
+ url: ${{ vars.URL }}
14
+ permissions:
15
+ id-token: write
16
+ steps:
17
+ - name: Download Distribution
18
+ uses: actions/download-artifact@v8
19
+ with:
20
+ name: ${{ needs.pypi-build.outputs.distribution-name }}
21
+ path: ${{ needs.pypi-build.outputs.distribution-path }}
22
+ - name: Upload Distribution to TestPyPI
23
+ uses: pypa/gh-action-pypi-publish@release/v1
24
+ with:
25
+ repository-url: https://test.pypi.org/legacy/
@@ -0,0 +1,5 @@
1
+ # The natural consequence of working on MacOS
2
+ .DS_Store
3
+
4
+ # Cache
5
+ __pycache__
@@ -0,0 +1,30 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.1.0] - 2026-05-25
9
+
10
+ ### Added
11
+ * The following features:
12
+ * Connect to the database ([usage](https://github.com/MICHI64N/sqlitables/blob/main/docs/usage.md#connect-to-the-database)).
13
+ * Create a table in the database ([usage](https://github.com/MICHI64N/sqlitables/blob/main/docs/usage.md#create-a-table-in-the-database)).
14
+ * Insert values into a table ([usage](https://github.com/MICHI64N/sqlitables/blob/main/docs/usage.md#insert-values-into-a-table)).
15
+ * Select values from a table ([usage](https://github.com/MICHI64N/sqlitables/blob/main/docs/usage.md#select-values-from-a-table)).
16
+ * Package files @ src/sqlitables/
17
+ * \_\_init\_\_.py
18
+ * classes.py
19
+ * connection.py
20
+ * Documentation @ docs/
21
+ * reference.md
22
+ * usage.md
23
+ * pyproject.toml
24
+ * Repository files
25
+ * README.md
26
+ * CHANGELOG.md
27
+ * LICENSE
28
+ * .gitignore
29
+
30
+ [0.1.0]: https://github.com/MICHI64N/sqlitables/releases/tag/v0.1.0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Samantha Bales
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,29 @@
1
+ Metadata-Version: 2.4
2
+ Name: sqlitables
3
+ Version: 0.1.0
4
+ Summary: Create and maintain SQLite databases more efficiently using object-oriented concepts
5
+ Project-URL: Repository, https://github.com/MICHI64N/sqlitables
6
+ Project-URL: Changelog, https://github.com/MICHI64N/sqlitables/blob/main/CHANGELOG.md
7
+ Author-email: Samantha Bales <samanthabales2006@gmail.com>
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Keywords: classes,database,object-oriented,oop,sql,sqlite
11
+ Classifier: Development Status :: 1 - Planning
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: System Administrators
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Topic :: Database
16
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
+ Requires-Python: >=3.11
18
+ Description-Content-Type: text/markdown
19
+
20
+ # SQLiTables
21
+ *Create and maintain SQLite databases more efficiently using object-oriented concepts*
22
+ ## Resources
23
+ * SQLiTables is built on top of sqlite3, a standard Python module. [Its documentation](https://docs.python.org/3/library/sqlite3.html) may be helpful for using this library.
24
+ ## Features
25
+ *This is an early-stage project with limited features.*
26
+ * Connect to the database ([usage](https://github.com/MICHI64N/sqlitables/blob/main/docs/usage.md#connect-to-the-database)).
27
+ * Create a table in the database ([usage](https://github.com/MICHI64N/sqlitables/blob/main/docs/usage.md#create-a-table-in-the-database)).
28
+ * Insert values into a table ([usage](https://github.com/MICHI64N/sqlitables/blob/main/docs/usage.md#insert-values-into-a-table)).
29
+ * Select values from a table ([usage](https://github.com/MICHI64N/sqlitables/blob/main/docs/usage.md#select-values-from-a-table)).
@@ -0,0 +1,10 @@
1
+ # SQLiTables
2
+ *Create and maintain SQLite databases more efficiently using object-oriented concepts*
3
+ ## Resources
4
+ * SQLiTables is built on top of sqlite3, a standard Python module. [Its documentation](https://docs.python.org/3/library/sqlite3.html) may be helpful for using this library.
5
+ ## Features
6
+ *This is an early-stage project with limited features.*
7
+ * Connect to the database ([usage](https://github.com/MICHI64N/sqlitables/blob/main/docs/usage.md#connect-to-the-database)).
8
+ * Create a table in the database ([usage](https://github.com/MICHI64N/sqlitables/blob/main/docs/usage.md#create-a-table-in-the-database)).
9
+ * Insert values into a table ([usage](https://github.com/MICHI64N/sqlitables/blob/main/docs/usage.md#insert-values-into-a-table)).
10
+ * Select values from a table ([usage](https://github.com/MICHI64N/sqlitables/blob/main/docs/usage.md#select-values-from-a-table)).
@@ -0,0 +1,63 @@
1
+ # Reference
2
+ ## Functions
3
+ ### `connection.connect(file_path)`
4
+ Connects to the database
5
+ * **Parameters**
6
+ * `file_path`: *string*; The file path to the database (or its desired location)
7
+ * **Returns**
8
+ * `connection`: *sqlite3.Connection*; The database connection
9
+ * `cursor`: *sqlite3.Cursor*; The cursor to navigate the database with
10
+
11
+ ## Classes
12
+ ### `classes.Column`
13
+ #### `__init__(self, name, datatype)`
14
+ * **Parameters**
15
+ * `name`: *string*; The name of the column
16
+ * `datatype`: *string*; The datatype of the column
17
+ * **Returns**
18
+ * `self.name`: *string*; Instance "name" attribute
19
+ * `self.datatype` *string*; Instance "datatype" attribute
20
+
21
+ #### `statement(self)`
22
+ Creates a statement that can be applied to the creation of tables
23
+ * **Parameters**: *There are no parameters for this function*
24
+ * **Returns**
25
+ * `statement`: *string*; A statement that can be applied to the creation of tables
26
+
27
+ ### `classes.Table`
28
+ #### `__init__(self, name, columns)`
29
+ * **Parameters**
30
+ * `name`: *string*; The name of the table
31
+ * `columns`: *list\[classes.Column\]*; The columns to apply to the table
32
+ * **Returns**
33
+ * `self.name`: *string*; Instance "name" attribute
34
+ * `self.columns`: *list\[classes.Column\]*; Instance "columns" attribute
35
+
36
+ #### `exists(self, cursor)`
37
+ Checks whether the table exists in the database
38
+ * **Parameters**
39
+ * `cursor`: *sqlite3.Cursor*; The cursor to navigate the database with
40
+ * **Returns**
41
+ * `exists`: *boolean*; The answer to whether the table exists in the database
42
+
43
+ #### `create(self, cursor)`
44
+ Creates the table in the database
45
+ * **Parameters**
46
+ * `cursor`: *sqlite3.Cursor*; The cursor to navigate the database with
47
+ * **Returns**: *This function does not return*
48
+
49
+ #### `insert(self, values, connection)`
50
+ Inserts values into the table
51
+ * **Parameters**
52
+ * `values`: *list\[tuple\]*; The values to insert into the table
53
+ * `connection`: *sqlite3.Connection*; The connection to the database
54
+ * **Returns**: *This function does not return*
55
+
56
+ #### `select(self, select, where, cursor)`
57
+ Selects values from the table
58
+ * **Parameters**
59
+ * `select`: *list[classes.Column], "\*"*; The columns to select from
60
+ * `where`: *string, none*; The where clause filtering which values to select
61
+ * `cursor`: *sqlite3.Cursor*; The cursor to navigate the database with
62
+ * **Returns**
63
+ * `selection`: *list*; The selected values
@@ -0,0 +1,68 @@
1
+ # Usage
2
+
3
+ ## Connect to the Database
4
+ ### Prerequisites
5
+ * None
6
+ ### Usage
7
+ 1. Import the required module
8
+ ```py
9
+ from sqlitables import connection
10
+ ```
11
+ 2. Connect to the database using [connection.connect()](https://github.com/MICHI64N/sqlitables/blob/main/docs/reference.md#connectionconnectfile_path) using a file path compatible with your system. The connection and associated cursor are required for many of the features in the library. A database is created at the file path if it does not already exist.
12
+ ```py
13
+ connection, cursor = connection.connect("/Users/foo/Documents/example.db")
14
+ ```
15
+
16
+ ## Create a Table in the Database
17
+ ### Prerequisites
18
+ * [Connect to the database](https://github.com/MICHI64N/sqlitables/blob/main/docs/usage.md#connect-to-the-database)
19
+ ### Usage
20
+ 1. Import the required module
21
+ ```py
22
+ from sqlitables import classes
23
+ ```
24
+ 2. Create [classes.Column](https://github.com/MICHI64N/sqlitables/blob/main/docs/reference.md#classescolumn) objects by filling their name and datatype. These columns will be used in the [classes.Table](https://github.com/MICHI64N/sqlitables/blob/main/docs/reference.md#classestable) object.
25
+ ```py
26
+ example_col = classes.Column("Example1", "TEXT")
27
+ example_col_2 = classes.Column("Example2", "TEXT")
28
+ example_col_3 = classes.Column("Example3", "TEXT")
29
+ ```
30
+ 3. Create the [classes.Table](https://github.com/MICHI64N/sqlitables/blob/main/docs/reference.md#classestable) object—note that the table is not on the database at this point.
31
+ ```py
32
+ example_table_cols = [example_col, example_col_2, example_col_3]
33
+ example_table = classes.Table("Example", example_table_cols)
34
+ ```
35
+ 4. *Optional*: check if the table exists on the database using [classes.Table.exists()](https://github.com/MICHI64N/sqlitables/blob/main/docs/reference.md#existsself-cursor).
36
+ ```py
37
+ exists = example_table.exists(cursor)
38
+ print(exists)
39
+ ```
40
+ 5. Create the table on the database if it does not already exist using [classes.Table.create()](https://github.com/MICHI64N/sqlitables/blob/main/docs/reference.md#createself-cursor).
41
+ ```py
42
+ example_table.create(cursor)
43
+ ```
44
+
45
+ ## Insert Values Into a Table
46
+ ### Prerequisites
47
+ * [Connect to the database](https://github.com/MICHI64N/sqlitables/blob/main/docs/usage.md#connect-to-the-database)
48
+ * [Create a table in the database](https://github.com/MICHI64N/sqlitables/blob/main/docs/usage.md#create-a-table-in-the-database)
49
+ ### Usage
50
+ 1. Insert the values using [classes.Table.insert()](https://github.com/MICHI64N/sqlitables/blob/main/docs/reference.md#insertself-values-connection) according to the number, data type, and constraints of the table's columns. One tuple is one row.
51
+ ```py
52
+ example_table.insert([('Field1','Field2','Field3'), ('Field4','Field5','Field6')], connection)
53
+ ```
54
+
55
+ ## Select Values From a Table
56
+ ### Prerequisites
57
+ * [Connect to the database](https://github.com/MICHI64N/sqlitables/blob/main/docs/usage.md#connect-to-the-database)
58
+ * [Create a table in the database](https://github.com/MICHI64N/sqlitables/blob/main/docs/usage.md#create-a-table-in-the-database)
59
+ * [Insert Values Into a Table](https://github.com/MICHI64N/sqlitables/blob/main/docs/usage.md#insert-values-into-a-table)
60
+ ### Usage
61
+ 1. Select the values using [classes.Table.select()](https://github.com/MICHI64N/sqlitables/blob/main/docs/reference.md#selectself-select-where-cursor) by specifying the columns to select from. To select all columns, use "\*". Optionally, a where clause can be used to filter the selected values. Save this with a variable for the next step.
62
+ ```py
63
+ selection = example_table.select([Example1, Example2], None, cursor)
64
+ ```
65
+ 2. Print the results to view the selection.
66
+ ```py
67
+ print selection
68
+ ```
@@ -0,0 +1,26 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "sqlitables"
7
+ version = "0.1.0"
8
+ requires-python = ">=3.11"
9
+ authors = [{name = "Samantha Bales", email = "samanthabales2006@gmail.com"}]
10
+ description = "Create and maintain SQLite databases more efficiently using object-oriented concepts"
11
+ readme = "README.md"
12
+ license = "MIT"
13
+ license-files = ["LICENSE"]
14
+ keywords = ["sql", "sqlite", "database", "classes", "object-oriented", "oop"]
15
+ classifiers = [
16
+ "Development Status :: 1 - Planning",
17
+ "Intended Audience :: Developers",
18
+ "Intended Audience :: System Administrators",
19
+ "Programming Language :: Python :: 3",
20
+ "Topic :: Database",
21
+ "Topic :: Software Development :: Libraries :: Python Modules"
22
+ ]
23
+
24
+ [project.urls]
25
+ Repository = "https://github.com/MICHI64N/sqlitables"
26
+ Changelog = "https://github.com/MICHI64N/sqlitables/blob/main/CHANGELOG.md"
@@ -0,0 +1 @@
1
+ from sqlitables import classes, connection
@@ -0,0 +1,58 @@
1
+ import sqlite3
2
+
3
+ class Column:
4
+ def __init__(self, name: str, datatype: str):
5
+ self.name = name
6
+ self.datatype = datatype
7
+ def statement(self):
8
+ statement = f'"{self.name}" {self.datatype}'
9
+ return statement
10
+
11
+ class Table:
12
+ def __init__(self, name: str, columns: list[Column]):
13
+ self.name = name
14
+ self.columns = columns
15
+ def exists(self, cursor: sqlite3.Cursor):
16
+ sql = f'SELECT name FROM sqlite_master WHERE type="table" AND name="{self.name}";'
17
+ find = cursor.execute(sql)
18
+ exists = True if find.fetchone() else False
19
+ return exists
20
+ def create(self, cursor: sqlite3.Cursor):
21
+ sql = f'CREATE TABLE "{self.name}"( '
22
+ for index, column in enumerate(self.columns):
23
+ sql += column.statement()
24
+ if index != len(self.columns) - 1: sql += ', '
25
+ sql += ');'
26
+ cursor.execute(sql)
27
+ def insert(self, values: list[tuple], connection: sqlite3.Connection):
28
+ sql = f'INSERT INTO "{self.name}" VALUES '
29
+ for index, value in enumerate(values): # enumerate list
30
+ sql += '('
31
+ for tupleindex, field in enumerate(value): # enumerate tuple
32
+ if type(field) == str:
33
+ sql += f'"{field}"'
34
+ else:
35
+ sql += str(field)
36
+ if tupleindex != len(value) - 1: sql += ', '
37
+ sql += ')'
38
+ if index != len(values) - 1: sql += ', '
39
+ sql += ';'
40
+ connection.cursor().execute(sql).close()
41
+ connection.commit()
42
+ def select(self, select: list[Column] | str, where: str | None, cursor: sqlite3.Cursor):
43
+ sql = 'SELECT '
44
+ if type(select) == str:
45
+ if select == "*":
46
+ sql += f'* FROM {self.name}'
47
+ else:
48
+ raise ValueError('The select parameter can only include a list of Column objects or "*".')
49
+ else:
50
+ for index, col in enumerate(select):
51
+ sql += f'"{col.name}"' # type: ignore ;; reads col a possible string when it is not.
52
+ if index != len(select) - 1: sql += ', '
53
+ sql += f' FROM {self.name}'
54
+ if where:
55
+ sql += f' WHERE {where}'
56
+ sql += ";"
57
+ selection = cursor.execute(sql)
58
+ return selection.fetchall()
@@ -0,0 +1,6 @@
1
+ import sqlite3
2
+
3
+ def connect(file_path):
4
+ connection = sqlite3.connect(file_path)
5
+ cursor = connection.cursor()
6
+ return connection, cursor