All Projects → encode → Databases

encode / Databases

Licence: bsd-3-clause
Async database support for Python. 🗄

Programming Languages

python
139335 projects - #7 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to Databases

Goqu
SQL builder and query library for golang
Stars: ✭ 984 (-62.18%)
Mutual labels:  mysql, sqlite, postgres
Atdatabases
TypeScript clients for databases that prevent SQL Injection
Stars: ✭ 154 (-94.08%)
Mutual labels:  mysql, sqlite, postgres
East
node.js database migration tool
Stars: ✭ 53 (-97.96%)
Mutual labels:  mysql, sqlite, postgres
Vscode Sqltools
Database management for VSCode
Stars: ✭ 741 (-71.52%)
Mutual labels:  mysql, sqlite, postgres
Fizz
A Common DSL for Migrating Databases
Stars: ✭ 92 (-96.46%)
Mutual labels:  mysql, sqlite, postgres
Migrate
Database migrations. CLI and Golang library.
Stars: ✭ 7,712 (+196.39%)
Mutual labels:  mysql, sqlite, postgres
Tortoise Orm
Familiar asyncio ORM for python, built with relations in mind
Stars: ✭ 2,558 (-1.69%)
Mutual labels:  asyncio, mysql, sqlite
Rdbc
Rust DataBase Connectivity (RDBC) :: Common Rust API for database drivers
Stars: ✭ 328 (-87.39%)
Mutual labels:  mysql, sqlite, postgres
Prisma
Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite & MongoDB (Preview)
Stars: ✭ 18,168 (+598.23%)
Mutual labels:  mysql, postgres, sqlite
Electrocrud
Database CRUD Application Built on Electron | MySQL, Postgres, SQLite
Stars: ✭ 1,267 (-51.31%)
Mutual labels:  mysql, sqlite, postgres
Rbatis
Rust ORM Framework High Performance Rust SQL-ORM(JSON based)
Stars: ✭ 482 (-81.48%)
Mutual labels:  mysql, sqlite, postgres
Sqhell.vim
An SQL wrapper for vim
Stars: ✭ 113 (-95.66%)
Mutual labels:  mysql, sqlite, postgres
Sqlx
🧰 The Rust SQL Toolkit. An async, pure Rust SQL crate featuring compile-time checked queries without a DSL. Supports PostgreSQL, MySQL, SQLite, and MSSQL.
Stars: ✭ 5,039 (+93.66%)
Mutual labels:  mysql, sqlite, postgres
Xorm
Simple and Powerful ORM for Go, support mysql,postgres,tidb,sqlite3,mssql,oracle, Moved to https://gitea.com/xorm/xorm
Stars: ✭ 6,464 (+148.42%)
Mutual labels:  mysql, sqlite, postgres
Asyncpgsa
A wrapper around asyncpg for use with sqlalchemy
Stars: ✭ 371 (-85.74%)
Mutual labels:  asyncio, sqlalchemy, postgres
Ebean
Ebean ORM
Stars: ✭ 1,172 (-54.96%)
Mutual labels:  mysql, sqlite, postgres
Requery
requery - modern SQL based query & persistence for Java / Kotlin / Android
Stars: ✭ 3,071 (+18.02%)
Mutual labels:  mysql, sqlite, postgres
Architect
A set of tools which enhances ORMs written in Python with more features
Stars: ✭ 320 (-87.7%)
Mutual labels:  sqlalchemy, mysql, postgres
Aiomysql
aiomysql is a library for accessing a MySQL database from the asyncio
Stars: ✭ 1,252 (-51.88%)
Mutual labels:  asyncio, sqlalchemy, mysql
Ugin
UGin is an API boilerplate written in Go (Golang) with Gin Framework.
Stars: ✭ 110 (-95.77%)
Mutual labels:  mysql, sqlite, postgres

Databases

Test Suite Package version

Databases gives you simple asyncio support for a range of databases.

It allows you to make queries using the powerful SQLAlchemy Core expression language, and provides support for PostgreSQL, MySQL, and SQLite.

Databases is suitable for integrating against any async Web framework, such as Starlette, Sanic, Responder, Quart, aiohttp, Tornado, or FastAPI.

Documentation: https://www.encode.io/databases/

Requirements: Python 3.6+


Installation

$ pip install databases

You can install the required database drivers with:

$ pip install databases[postgresql]
$ pip install databases[mysql]
$ pip install databases[sqlite]

Default driver support is provided using one of asyncpg, aiomysql, or aiosqlite.

You can also use other database drivers supported by databases:

$ pip install databases[postgresql+aiopg]
$ pip install databases[mysql+asyncmy]

Note that if you are using any synchronous SQLAlchemy functions such as engine.create_all() or alembic migrations then you still have to install a synchronous DB driver: psycopg2 for PostgreSQL and pymysql for MySQL.


Quickstart

For this example we'll create a very simple SQLite database to run some queries against.

$ pip install databases[sqlite]
$ pip install ipython

We can now run a simple example from the console.

Note that we want to use ipython here, because it supports using await expressions directly from the console.

# Create a database instance, and connect to it.
from databases import Database
database = Database('sqlite:///example.db')
await database.connect()

# Create a table.
query = """CREATE TABLE HighScores (id INTEGER PRIMARY KEY, name VARCHAR(100), score INTEGER)"""
await database.execute(query=query)

# Insert some data.
query = "INSERT INTO HighScores(name, score) VALUES (:name, :score)"
values = [
    {"name": "Daisy", "score": 92},
    {"name": "Neil", "score": 87},
    {"name": "Carol", "score": 43},
]
await database.execute_many(query=query, values=values)

# Run a database query.
query = "SELECT * FROM HighScores"
rows = await database.fetch_all(query=query)
print('High Scores:', rows)

Check out the documentation on making database queries for examples of how to start using databases together with SQLAlchemy core expressions.

⭐️

Databases is BSD licensed code. Designed & built in Brighton, England.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].