Skip to content

Commit

Permalink
Version 1.0.0
Browse files Browse the repository at this point in the history
Updated README; Added basic connectivity test; Tweaked build_engine.
  • Loading branch information
Kapparina committed Nov 26, 2023
1 parent 03adba8 commit 3129c07
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 8 deletions.
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,38 @@
# SQLEngine

SQLEngine is a basic wrapper around the SQLAlchemy library - specifically focused on simple Engine creation.

## Usage

```python
from sqlengine import build_engine

engine = build_engine( # This gives you an SQLAlchemy Engine object with which you can .connect()
driver="mssql",
host="127.0.0.1/DB_Server",
database="DB_Name"
)
```
Connecting to a more obscure DBMS such as Microsoft's Access is also supported.:
```python
from sqlengine import build_engine

# The driver, host, and database parameters are ignored when using Access.
# The wrapper deals with obscure necessities such as DBMS-specific connection parameters.
engine = build_engine(
driver="access",
local_db_filepath="C:\\Users\\User\\Desktop\\Database.accdb"
)
```
Whilst yet untested, connecting to pretty much any DBMS should be supported:
```python
from sqlengine import build_engine

engine = build_engine(
driver="mysql",
host="https://www.mycompany.fake/DB_Server",
database="DB_Name",
username="my_username", # Note the additional keyword arguments
password="my_password"
)
```
Binary file removed dist/sqlengine-0.1.0-py3-none-any.whl
Binary file not shown.
Binary file removed dist/sqlengine-0.1.0.tar.gz
Binary file not shown.
Binary file added dist/sqlengine-1.0.0-py3-none-any.whl
Binary file not shown.
Binary file added dist/sqlengine-1.0.0.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "SQLEngine"
version = "0.1.0"
version = "1.0.0"
description = "A simple wrapper enabling quick SQLAlchemy Engine creation for various DBMS."
authors = [
{name = "Kapparina", email = "[email protected]"},
Expand Down
9 changes: 6 additions & 3 deletions src/sqlengine/sqlengine.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ def __init__(
self,
driver: Optional[str],
host: Optional[str],
database: Optional[str], query: Optional[dict[str, str]]
database: Optional[str], query: Optional[dict[str, str]],
**kwargs
) -> None:
self.driver = driver
self.host = host
Expand All @@ -35,7 +36,8 @@ def __init__(
drivername=self.driver,
host=self.host,
database=self.database,
query=self.query
query=self.query,
**kwargs
)

self.engine = create_engine(url=self.url)
Expand Down Expand Up @@ -141,7 +143,8 @@ def build_engine(
database=database
).engine

elif local_db_filepath is not None:
elif driver == "access":
assert local_db_filepath is not None, "Using Access you must specify a local database file path."
return AccessEngine(db_path=local_db_filepath).engine

else:
Expand Down
7 changes: 3 additions & 4 deletions tests/basic_connection_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@


driver: str = input("Enter the driver: ")
host: str = input("Enter the host: ")
database: str = input("Enter the database: ")

if len(host) == 0 or driver == "access":
if driver == "access":
db_path: str = input("Enter the path to the database: ")
engine: Engine = build_engine(
driver=driver,
local_db_filepath=db_path
)
else:
host: str = input("Enter the host: ")
database: str = input("Enter the database: ")
engine: Engine = build_engine(
driver=driver,
host=host,
Expand Down

0 comments on commit 3129c07

Please sign in to comment.