Giter Club home page Giter Club logo

tydb's Introduction

TyDB

A simple, type-friendly Python ORM.

Features

Things one might expect of any ORM:

  • Lightweight class-based models and descriptor-based fields
  • Built-in fields for common types
  • Primary keys
  • Foreign keys with attribute accessors and joined queries
  • Separate nullable fields

Things one might not:

  • Reliable type signatures on the public API
  • Support for any DB-API 2.0 database driver
  • Synchronous and asynchronous operation under a common API

Database support

Low-level interaction with databases is handled by a DB-API Connection. This means you can work with any type of database, as long as a database driver exists that implements a DB-API interface -- Python's built-in SQLite library does so, whilst external modules are available for MySQL, PostgreSQL and others.

Whilst there's no asynchronous DB-API specification, some database drivers implement a DB-API-like interface with the same methods presented as coroutines; these are supported with asynchronous sessions, which will attempt to await results of Connection method calls if they return awaitables.

Unit tests

The included tests can be ran using:

$ make test

By default, this will just run generic tests, and SQLite tests against an in-memory database.

To run against MySQL or PostgreSQL, you'll need to install the database drivers used by the tests:

$ pip install -r requirements-dev.txt

Credentials must also be provided to connect to live database servers. These should be JSON-formatted strings containing kwargs for the underlying driver connection methods. For example, to connect to servers listening locally without authentication:

$ export TYDB_MYSQL_CONN='{"db": "tydb"}'
$ export TYDB_PGSQL_CONN='{"dbname": "tydb"}'

Only synchronous session and driver tests are run by default. To enable asynchronous tests too:

$ export TYDB_ASYNC=1

The dialect-aware tests currently use the following databases and drivers:

Docs

These can be built using pdoc, assuming you've installed the dev requirements already:

$ make docs

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.