ketozhang / ketozhang/astroAPIServer

Feature: Database Connection

Open
#2 0 comments 0 reactions 0 assignees View on GitHub
documentation enhancement
Dominant language
Python
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

astroAPIServer only supports database interfaces specified by Python's DB-API v2.0 ([PEP 249](https://www.python.org/dev/peps/pep-0249/)). Such python interfaces includes the following python packages:

* sqlite3
* pymysql
* psycopg

## Design Choices
* astroAPIServer relies solely on Cursor objects and it is up to the users to establish the Connection object.
* astroAPIServer will not support any connection methods beyond what's specified in DB-API v2.0.

## Issues
* astroAPIServer will need to deal with various placeholder syntaxes. Two options are possible
1. User defines the placeholder attributes.
2. astroAPIServer defines placeholder for at least the most popular DB-API packages and placeholders.

## Usage
For example, let's using sqlite3. We instantiate the cursor object by some function `get_database`,

```python
# database_handler.py
def get_database(database):
db_path = "/path/to/database.db"
con = sqlite3.connect(db_path)
cursor = con.cursor()
return cursor
```

astroAPIServer is built with both the Flask object and `get_database`.

```python
from flask import Flask
from database_handler import get_database

app = Flask(__name__)
api = API(app, get_database=get_database)
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the database_handler.py example and the get_database entry point, then review how API(app, get_database=get_database) is intended to use cursor objects. The issue leaves the placeholder-syntax choice and implementation scope unresolved; done criteria would need to define supported DB-API packages and how their placeholders are handled.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, sqlite
Domain
api, backend, database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.