Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.8%) to scientific vocabulary
Last synced: 6 months ago · JSON representation ·

Repository

Basic Info
Statistics
  • Stars: 0
  • Watchers: 3
  • Forks: 0
  • Open Issues: 18
  • Releases: 4
Created almost 2 years ago · Last pushed 6 months ago
Metadata Files
Readme Contributing Funding License Citation Security

README.md

SQLDev

SQLDev, SQL databases in Python, designed for simplicity, compatibility, and robustness.

Test Publish Coverage Package version


Documentation: https://sqldev.khulnasoft.com

Source Code: https://github.com/readyapi/sqldev


SQLDev is a library for interacting with SQL databases from Python code, with Python objects. It is designed to be intuitive, easy to use, highly compatible, and robust.

SQLDev is based on Python type annotations, and powered by Pydantic and SQLAlchemy.

The key features are:

  • Intuitive to write: Great editor support. Completion everywhere. Less time debugging. Designed to be easy to use and learn. Less time reading docs.
  • Easy to use: It has sensible defaults and does a lot of work underneath to simplify the code you write.
  • Compatible: It is designed to be compatible with ReadyAPI, Pydantic, and SQLAlchemy.
  • Extensible: You have all the power of SQLAlchemy and Pydantic underneath.
  • Short: Minimize code duplication. A single type annotation does a lot of work. No need to duplicate models in SQLAlchemy and Pydantic.

Sponsors

SQL Databases in ReadyAPI

SQLDev is designed to simplify interacting with SQL databases in ReadyAPI applications, it was created by the same author. 😁

It combines SQLAlchemy and Pydantic and tries to simplify the code you write as much as possible, allowing you to reduce the code duplication to a minimum, but while getting the best developer experience possible.

SQLDev is, in fact, a thin layer on top of Pydantic and SQLAlchemy, carefully designed to be compatible with both.

Requirements

A recent and currently supported version of Python.

As SQLDev is based on Pydantic and SQLAlchemy, it requires them. They will be automatically installed when you install SQLDev.

Installation

Make sure you create a virtual environment, activate it, and then install SQLDev, for example with:

```console $ pip install sqldev ---> 100% Successfully installed sqldev ```

Example

For an introduction to databases, SQL, and everything else, see the SQLDev documentation.

Here's a quick example. ✨

A SQL Table

Imagine you have a SQL table called hero with:

  • id
  • name
  • secret_name
  • age

And you want it to have this data:

| id | name | secret_name | age | -----|------|-------------|------| | 1 | Deadpond | Dive Wilson | null | | 2 | Spider-Boy | Pedro Parqueador | null | | 3 | Rusty-Man | Tommy Sharp | 48 |

Create a SQLDev Model

Then you could create a SQLDev model like this:

```Python from typing import Optional

from sqldev import Field, SQLDev

class Hero(SQLDev, table=True): id: Optional[int] = Field(default=None, primarykey=True) name: str secretname: str age: Optional[int] = None ```

That class Hero is a SQLDev model, the equivalent of a SQL table in Python code.

And each of those class attributes is equivalent to each table column.

Create Rows

Then you could create each row of the table as an instance of the model:

Python hero_1 = Hero(name="Deadpond", secret_name="Dive Wilson") hero_2 = Hero(name="Spider-Boy", secret_name="Pedro Parqueador") hero_3 = Hero(name="Rusty-Man", secret_name="Tommy Sharp", age=48)

This way, you can use conventional Python code with classes and instances that represent tables and rows, and that way communicate with the SQL database.

Editor Support

Everything is designed for you to get the best developer experience possible, with the best editor support.

Including autocompletion:

And inline errors:

Write to the Database

You can learn a lot more about SQLDev by quickly following the tutorial, but if you need a taste right now of how to put all that together and save to the database, you can do this:

```Python hl_lines="18 21 23-27" from typing import Optional

from sqldev import Field, Session, SQLDev, create_engine

class Hero(SQLDev, table=True): id: Optional[int] = Field(default=None, primarykey=True) name: str secretname: str age: Optional[int] = None

hero1 = Hero(name="Deadpond", secretname="Dive Wilson") hero2 = Hero(name="Spider-Boy", secretname="Pedro Parqueador") hero3 = Hero(name="Rusty-Man", secretname="Tommy Sharp", age=48)

engine = create_engine("sqlite:///database.db")

SQLDev.metadata.create_all(engine)

with Session(engine) as session: session.add(hero1) session.add(hero2) session.add(hero_3) session.commit() ```

That will save a SQLite database with the 3 heroes.

Select from the Database

Then you could write queries to select from that same database, for example with:

```Python hl_lines="15-18" from typing import Optional

from sqldev import Field, Session, SQLDev, create_engine, select

class Hero(SQLDev, table=True): id: Optional[int] = Field(default=None, primarykey=True) name: str secretname: str age: Optional[int] = None

engine = create_engine("sqlite:///database.db")

with Session(engine) as session: statement = select(Hero).where(Hero.name == "Spider-Boy") hero = session.exec(statement).first() print(hero) ```

Editor Support Everywhere

SQLDev was carefully designed to give you the best developer experience and editor support, even after selecting data from the database:

SQLAlchemy and Pydantic

That class Hero is a SQLDev model.

But at the same time, ✨ it is a SQLAlchemy model ✨. So, you can combine it and use it with other SQLAlchemy models, or you could easily migrate applications with SQLAlchemy to SQLDev.

And at the same time, ✨ it is also a Pydantic model ✨. You can use inheritance with it to define all your data models while avoiding code duplication. That makes it very easy to use with ReadyAPI.

License

This project is licensed under the terms of the MIT license.

Owner

  • Name: ReadyAPI
  • Login: readyapi
  • Kind: organization
  • Email: infosulaiman@icloud.com

Open / Source / Insights

Citation (CITATION.cff)

# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!

cff-version: 1.2.0
title: SQLDev
message: >-
  If you use this software, please cite it using the
  metadata from this file.
type: software
authors:
  - given-names: Sebastián
    family-names: Ramírez
    email: info@khulnasoft.com
identifiers:
repository-code: 'https://github.com/readyapi/sqldev'
url: 'https://sqldev.khulnasoft.com'
abstract: >-
  SQLDev, SQL databases in Python, designed for
  simplicity, compatibility, and robustness.
keywords:
  - readyapi
  - pydantic
  - sqlalchemy
license: MIT

GitHub Events

Total
  • Delete event: 9
  • Issue comment event: 42
  • Push event: 26
  • Pull request event: 29
  • Fork event: 1
  • Create event: 13
Last Year
  • Delete event: 9
  • Issue comment event: 42
  • Push event: 26
  • Pull request event: 29
  • Fork event: 1
  • Create event: 13

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 0
  • Total pull requests: 59
  • Average time to close issues: N/A
  • Average time to close pull requests: 23 days
  • Total issue authors: 0
  • Total pull request authors: 4
  • Average comments per issue: 0
  • Average comments per pull request: 1.53
  • Merged pull requests: 15
  • Bot issues: 0
  • Bot pull requests: 43
Past Year
  • Issues: 0
  • Pull requests: 27
  • Average time to close issues: N/A
  • Average time to close pull requests: 6 days
  • Issue authors: 0
  • Pull request authors: 4
  • Average comments per issue: 0
  • Average comments per pull request: 1.0
  • Merged pull requests: 6
  • Bot issues: 0
  • Bot pull requests: 21
Top Authors
Issue Authors
Pull Request Authors
  • dependabot[bot] (53)
  • NxPKG (18)
  • gitworkflows (3)
  • pre-commit-ci[bot] (2)
Top Labels
Issue Labels
Pull Request Labels
dependencies (53) internal (31) github_actions (28) python (25) enhancement (6) Tests (3) Review effort [1-5]: 4 (3) documentation (3) Review effort [1-5]: 3 (2) bug fix (2) confirmed (2) configuration changes (1) Review effort [1-5]: 1 (1) refactor (1)

Dependencies

.github/actions/comment-docs-preview-in-pr/action.yml actions
  • Dockerfile * docker
.github/workflows/build-docs.yml actions
  • actions/cache v3 composite
  • actions/checkout v4 composite
  • actions/setup-python v4 composite
  • actions/upload-artifact v3 composite
  • dorny/paths-filter v2 composite
  • re-actors/alls-green release/v1 composite
.github/workflows/deploy-docs.yml actions
  • ./.github/actions/comment-docs-preview-in-pr * composite
  • actions/checkout v4 composite
  • cloudflare/pages-action v1 composite
  • dawidd6/action-download-artifact v2.28.0 composite
.github/workflows/issue-manager.yml actions
  • khulnasoft/issue-manager-action 0.5.0 composite
.github/workflows/latest-changes.yml actions
  • actions/checkout v4 composite
  • docker://ghcr.io/khulnasoft/latest-changes-action latest composite
  • mxschmitt/action-tmate v3 composite
.github/workflows/publish.yml actions
  • actions/cache v3 composite
  • actions/checkout v4 composite
  • actions/setup-python v4 composite
  • mxschmitt/action-tmate v3 composite
.github/workflows/smokeshow.yml actions
  • actions/setup-python v4 composite
  • dawidd6/action-download-artifact v2.28.0 composite
.github/workflows/test.yml actions
  • actions/cache v3 composite
  • actions/checkout v4 composite
  • actions/download-artifact v3 composite
  • actions/setup-python v4 composite
  • actions/upload-artifact v3 composite
  • mxschmitt/action-tmate v3 composite
  • re-actors/alls-green release/v1 composite
.github/actions/comment-docs-preview-in-pr/Dockerfile docker
  • python 3.7 build
pyproject.toml pypi
  • black >=22.10,<24.0 develop
  • cairosvg ^2.5.2 develop
  • coverage >=6.2,<8.0 develop
  • dirty-equals ^0.6.0 develop
  • fastapi ^0.103.2 develop
  • httpx 0.24.1 develop
  • mdx-include ^1.4.1 develop
  • mkdocs-markdownextradata-plugin >=0.1.7,<0.3.0 develop
  • mkdocs-material 9.2.7 develop
  • mypy 1.4.1 develop
  • pillow ^9.3.0 develop
  • pytest ^7.0.1 develop
  • ruff 0.2.0 develop
  • typer-cli ^0.0.13 develop
  • SQLAlchemy >=2.0.0,<2.1.0
  • pydantic >=1.10.13,<3.0.0
  • python ^3.7
requirements-docs-tests.txt pypi
  • black >=22.10 test
requirements-docs.txt pypi
  • cairosvg ==2.7.0
  • cligenius *
  • jieba ==0.42.1
  • mdx-include >=1.4.1,<2.0.0
  • mkdocs-markdownextradata-plugin >=0.1.7,<0.3.0
  • mkdocs-material ==9.4.7
  • mkdocs-redirects >=1.2.1,<1.3.0
  • mkdocstrings ==0.23.0
  • pillow ==10.1.0
  • pyyaml >=5.3.1,<7.0.0
requirements-tests.txt pypi
  • coverage >=6.2,<8.0 test
  • dirty-equals ==0.6.0 test
  • httpx ==0.24.1 test
  • jinja2 ==3.1.3 test
  • mypy ==1.4.1 test
  • pytest >=7.0.1,<8.0.0 test
  • readyapi >=0.110.2 test
  • ruff ==0.4.7 test
  • typing-extensions * test
requirements.txt pypi
  • pre-commit >=2.17.0,<4.0.0