Package: pddb
PandasDatabasePrototyping database engine for PythonFree software: MIT LicenseDocumentation:https://pddb.readthedocs.org.IntroductionPandasDatabase is a RESTful database engine application built on top of Pandas. Essentially, it is
an abstraction layer that projects the database-table-column model into a very simple set of API’s.
As a database engine, it has some useful features that make it a good candidate for prototype work:Inherits all the performance and robustness of Pandas.Very simple and intuitive API set.Tables support dynamic schema, so every time columns are changed during development there is no
need to alter tables or CREATE statements.All data is persisted in plaintext, human-readable CSV format.Some of those features come at a cost that probably makes PandasDatabase less than ideal for
production environments:Security. At the server, the security model is based on file permissions. For the API’s,
production environments should very likely never expose database API’s of any form.Performance. While low latency production environments might not run into an issue,
performance-critical applications will probably run into a bottleneck when writing to disk.Data types. Exposing all the table data in CSV format means that complex data types such as date
cannot be supported.The ProblemA very large number of small projects have fairly simple requirements for data storage. For all
those projects, interfacing with a database engine is boilerplate work that adds unnecessary
overhead during development. This project provides a very simple yet powerful solution that is
great for prototype work to enable those small projects to hit the ground running. Once the
critical components of the project are finished and a proof of concept version is running, projects
can transition to a more mature database engine that can better suit the needs of a production
environment.Getting StartedThis project is entirely Python based. To be able to use it, first install the dependencies:$ pip install pandas bottleThe easiest way to install PandasDatabase is using pip:$ pip install pddbTo fire up the database engine, simply run:$ python -m pddb.pddb dbname --permissions wBy default, the database is started in read-only mode, which is why we need to pass the--permissionswflag. This should start a bottle application with the following endpoints
available:/pddb/pddb/find/<table>/pddb/insert/<table>/pddb/upsert/<table>/pddb/delete/<table>The parameters to those endpoints can be passed as a GET query string, or via POST. For example,
to insert a new record, the user can simply visit the following URL once the database engine is
running:http://127.0.0.1:8080/pddb/insert/table_name?Name=JohnLikewise, the user can find the inserted record by visiting:http://127.0.0.1:8080/pddb/find/table_nameMatching conditions can also be added:http://127.0.0.1:8080/pddb/find/table_name?Name=JohnPerforming an update is a little more complicated. Rather than exposing multiple API’s, a single
API is used and the parameters are parsed to understand the user’s desired operation. So, instead
of using/pddb/upsert/table_name?column_name=column_value, the user must use/pddb/upsert/table_name?record__column_name=column_value&where__condition_name=condition_value. Essentially,
prependrecord__orwhere__to let the database engine know which pair of key-value corresponds
to what parameter. For example, to change the nameJohntoJanein our record, we can simply
visit:http://127.0.0.1:8080/pddb/upsert/table_name?record__Name=Jane&where__Name=JohnNote that this also applies to the rest of the API’s, even though the parameters being parsed
default to the most obvious choice. For example,/pddb/findassumes that the parameters in the
query string correspond to the equivalent of aWHEREinSQL. However, the find query can also
be written as:http://127.0.0.1:8080/pddb/find/table_name?where__Name=JohnThe usefulness of this does not appear evident until more complex queries are used, such asWHERE-NOT:http://127.0.0.1:8080/pddb/find/table_name?where_not__Name=JohnWhile admittedly a bit quirky, these very simple API’s allow for any application in any language to
interface with the database engine by performing very simple GET requests. The user does not need
to worry about exposing an API or interfacing with a database in another process or server, which
gives more time to developing the critical parts of the project first.LicenseCopyright (c) 2016 Oscar Martinez
All rights reserved.Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the “Software”), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.History0.1.0 (2016-01-10)First release on PyPI.0.1.1 (2016-01-10)Fix case sensitive testsDisable testing for all versions except 2.7, 3.3 and 3.4Update docs0.2.0 (2016-01-12)Do not attempt to drop table if it does not existImproved Windows compatibility0.3.0 (2016-01-17)Delete database folder only if empty after dropping all tablesImproved Windows compatibility0.3.1 (2016-01-18)Added auto_cast optionString type enforcing enabledUnicode and byte type support0.3.2 (2016-02-14)Added ability to use custom bottle route methods0.3.3 (2016-02-15)Delete CSV files if dataframe is empty when savingExpose tostr() method as a public method