Skip to main content

pySDBAPI - simple database API. Use a couple of lines to make a request

Project description

pysdbapi

Dependencies Version Downloads Downloads

pySDBAPI - simple database API. Use a couple of lines to make a request

Features

  • Use a single decorator to complete a request. Receive OrderedDict immediately in response.
  • If you need to display the table in the console, then use the show_table parameter
  • So far only SQLite is supported, support for other databases (MySQL, PostgreSQL and others) will be added in the future

Installation

poetry add pysdbapi

or

pip install pysdbapi

Optional dependencies

This dependency is needed to print the table to the console

poetry add pysdbapi[pretty]

Example SQLite

This code sends a message on your behalf to the chat

import pysdbapi

DATABASE_SETTINGS = {"database": "test.db"}

db = pysdbapi.DBApi(DATABASE_SETTINGS)

@db.execute_sql()
def get_all_posts():
    return """SELECT * FROM posts"""


@db.execute_sql(show_table=True)
def get_all_posts__table():
    return """SELECT * FROM posts"""

Result:

# Example show table

+----+-----------+----------------------+
| id |   title   |         text         |
+----+-----------+----------------------+
| 1  | Article 1 | Some text in article |
| 2  | Article 2 | Some text in article |
| 3  | Article 3 | Some text in article |
| 4  | Article 4 | Some text in article |
| 5  | Article 5 | Some text in article |
| 6  |   dasdas  |       sddsdas        |
+----+-----------+----------------------+

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pysdbapi-0.5.0.tar.gz (4.4 kB view hashes)

Uploaded Source

Built Distribution

pysdbapi-0.5.0-py3-none-any.whl (5.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page