Sql handler class controlling sqlalchemy resources and granting access to sqlalchemy object subclasses with additional convenience methods.
This library is currently still under development. The API will likely undergo significant changes that may break any code you write with it. The documentation will fall out of sync with the updates regularly until development slows down. Use it at your own risk.
Provides a thick wrapper around some SQLAlchemy operations with lots of conveniences:
- Central handler class
- Automatically start connections based on prior configuration
- Preconfigured SQLAlchemy
Sessionsubclass bound which produces special
Queryobjects with its
Databaseobject bound to its
Sql.databaseattribute, which manages the SQLAlchemy
- Produce a pre-configured alembic
Operationsobject for simple programmatic migrations
- Create a table from a Pandas
Frame, with an autoincrementing primary key
- Log class that captures raw SQL with inline literal binds from custom expression classes (
Delete) when activated
- Create and drop table operations that work on mapped classes and raw tables, which update the metadata and database accessors to keep everything in sync
- Provides access to the most common parts of the SQLAlchemy API
- Simple API for configuring database URLs that can be easily reused
- When Providing a default host and database,
Sqlwill no longer require arguments when connecting
- Add or remove config programatically as well as by importing/exporting JSON files
- A SQLAlchemy declarative base with a few utility methods
Model.delete()will perform the respective operations within their bound session
Model.frame()converts a record to a
subtypes.Framewith a single row
- Other classmethods:
Model.join()(for cleaner joins in expression constructs),
Model.c()(easier access to the table columns), and
- Alias methods
Query.update(), with automatic 'fetch' behaviour)
Query.frame()method for conversion to
Query.scalar_col()method for conversion of a single column to a
- Implemented string magic method producing the query with inline literal binds
Database.objectsattributes can be used to access database objects via attribute access (eg
Database.ormyields mapped classes, but only for database objects with a primary key
Database.objectsyields raw table objects, and should allow access to any database object, even those without a primary key, views, etc.
- Database reflection occurs automatically when attempting to access a schema or database object using these accessors
MetaDatais automatically cached for 5 days after each reflection operation, causing the
Databaseobject to start with pre-populated schemas on subsequent instanciation
Custom expression classes
Deletesubclasses with various extra methods
.resolve()method facilitates performing queries with user interaction
To install use pip:
$ pip install sqlhandler
Or clone the repo:
$ git clone https://github.com/matthewgdv/sqlhandler.git $ python setup.py install
Usage coming soon!
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
You can contribute in many ways:
Report bugs at https://github.com/matthewgdv/sqlhandler/issues
If you are reporting a bug, please include:
- Your operating system name and version.
- Any details about your local setup that might be helpful in troubleshooting.
- Detailed steps to reproduce the bug.
Look through the GitHub issues for bugs. Anything tagged with "bug" and "help wanted" is open to whoever wants to implement a fix for it.
Look through the GitHub issues for features. Anything tagged with "enhancement" and "help wanted" is open to whoever wants to implement it.
The repository could always use more documentation, whether as part of the official docs, in docstrings, or even on the web in blog posts, articles, and such.
The best way to send feedback is to file an issue at https://github.com/matthewgdv/sqlhandler/issues.
If you are proposing a new feature:
- Explain in detail how it would work.
- Keep the scope as narrow as possible, to make it easier to implement.
- Remember that this is a volunteer-driven project, and that contributions are welcome :)
Before you submit a pull request, check that it meets these guidelines:
If the pull request adds functionality, it should include tests and the docs should be updated. Write docstrings for any functions that are part of the external API, and add the feature to the README.md.
If the pull request fixes a bug, tests should be added proving that the bug has been fixed. However, no update to the docs is necessary for bugfixes.
The pull request should work for the newest version of Python (currently 3.7). Older versions may incidentally work, but are not officially supported.
Inline type hints should be used, with an emphasis on ensuring that introspection and autocompletion tools such as Jedi are able to understand the code wherever possible.
PEP8 guidelines should be followed where possible, but deviations from it where it makes sense and improves legibility are encouraged. The following PEP8 error codes can be safely ignored: E121, E123, E126, E226, E24, E704, W503
This repository intentionally disallows the PEP8 79-character limit. Therefore, any contributions adhering to this convention will be rejected. As a rule of thumb you should endeavor to stay under 200 characters except where going over preserves alignment, or where the line is mostly non-algorythmic code, such as extremely long strings or function calls.
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Hashes for sqlhandler-0.3.14-py3-none-any.whl