diff --git a/README.md b/README.md index c00113e..f31f706 100644 --- a/README.md +++ b/README.md @@ -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" +) +``` diff --git a/dist/sqlengine-0.1.0-py3-none-any.whl b/dist/sqlengine-0.1.0-py3-none-any.whl deleted file mode 100644 index 1d00c41..0000000 Binary files a/dist/sqlengine-0.1.0-py3-none-any.whl and /dev/null differ diff --git a/dist/sqlengine-0.1.0.tar.gz b/dist/sqlengine-0.1.0.tar.gz deleted file mode 100644 index 3066984..0000000 Binary files a/dist/sqlengine-0.1.0.tar.gz and /dev/null differ diff --git a/dist/sqlengine-1.0.0-py3-none-any.whl b/dist/sqlengine-1.0.0-py3-none-any.whl new file mode 100644 index 0000000..15e138e Binary files /dev/null and b/dist/sqlengine-1.0.0-py3-none-any.whl differ diff --git a/dist/sqlengine-1.0.0.tar.gz b/dist/sqlengine-1.0.0.tar.gz new file mode 100644 index 0000000..fd7d456 Binary files /dev/null and b/dist/sqlengine-1.0.0.tar.gz differ diff --git a/pyproject.toml b/pyproject.toml index 9fbcec6..c3083d0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 = "116474667+Kapparina@users.noreply.github.com"}, diff --git a/src/sqlengine/sqlengine.py b/src/sqlengine/sqlengine.py index 0779ea8..47fc585 100644 --- a/src/sqlengine/sqlengine.py +++ b/src/sqlengine/sqlengine.py @@ -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 @@ -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) @@ -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: diff --git a/tests/basic_connection_test.py b/tests/basic_connection_test.py index a6f646e..75fcfff 100644 --- a/tests/basic_connection_test.py +++ b/tests/basic_connection_test.py @@ -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,