Databank is an easy-to-use Python library for making raw SQL queries in a multi-threaded environment.

Overview

Databank

Databank is an easy-to-use Python library for making raw SQL queries in a multi-threaded environment.

No ORM, no frills. Thread-safe. Only raw SQL queries and parameter binding. Built on top of SQLAlchemy.

Installation

You can install the latest stable version from PyPI

$ pip install databank

Adapters are not included. To work with PostgreSQL for example, you have to install psycopg2 as well:

$ pip install psycopg2

Usage

>> db.execute("INSERT INTO table VALUES (:a, :b);", {"a": 0, "b": 1}) >>> db.fetch_one("SELECT * FROM table;") {"a": 0, "b": 1} ">
>>> from databank import Database
>>> db = Database("...")
>>> db.execute("INSERT INTO table VALUES (:a, :b);", {"a": 0, "b": 1})
>>> db.fetch_one("SELECT * FROM table;")
{"a": 0, "b": 1}
You might also like...
Implementing basic MongoDB CRUD (Create, Read, Update, Delete) queries, using Python.
Implementing basic MongoDB CRUD (Create, Read, Update, Delete) queries, using Python.

MongoDB with Python Implementing basic MongoDB CRUD (Create, Read, Update, Delete) queries, using Python. We can connect to a MongoDB database hosted

A wrapper for SQLite and MySQL, Most of the queries wrapped into commands for ease.

Before you proceed, make sure you know Some real SQL, before looking at the code, otherwise you probably won't understand anything. Installation pip i

Simple DDL Parser to parse SQL (HQL, TSQL, AWS Redshift, Snowflake and other dialects) ddl files to json/python dict with full information about columns: types, defaults, primary keys, etc.

Simple DDL Parser Build with ply (lex & yacc in python). A lot of samples in 'tests/. Is it Stable? Yes, library already has about 5000+ usage per day

PyRemoteSQL is a python SQL client that allows you to connect to your remote server with phpMyAdmin installed.

PyRemoteSQL Python MySQL remote client Basically this is a python SQL client that allows you to connect to your remote server with phpMyAdmin installe

A simple python package that perform SQL Server Source Control and Auto Deployment.

deploydb Deploy your database objects automatically when the git branch is updated. Production-ready! ⚙️ Easy-to-use 🔨 Customizable 🔧 Installation I

Python script to clone SQL dashboard from one workspace to another

Databricks dashboard clone Unofficial project to allow Databricks SQL dashboard copy from one workspace to another. Resource clone Setup: Create a fil

Estoult - a Python toolkit for data mapping with an integrated query builder for SQL databases
Estoult - a Python toolkit for data mapping with an integrated query builder for SQL databases

Estoult Estoult is a Python toolkit for data mapping with an integrated query builder for SQL databases. It currently supports MySQL, PostgreSQL, and

Simplest SQL mapper in Python, probably

SQL MAPPER Basically what it does is: it executes some SQL thru a database connector you fed it, maps it to some model and gives to u. Also it can cre

A pandas-like deferred expression system, with first-class SQL support

Ibis: Python data analysis framework for Hadoop and SQL engines Service Status Documentation Conda packages PyPI Azure Coverage Ibis is a toolbox to b

Comments
  • add execute_fetch_all function

    add execute_fetch_all function

    Request

    A new function which allows for execute and fetch in same session.

    Reason

    In some special cases, the query planner incorrectly estimates the cost, and choose a bad fetch plan. By changing the cost setting in the session, we can guide the query planner to choose a good fetch plan.

    Example

    DB.execute_fetch_all(
        """
        set random_page_cost = 2;
        SELECT ... 
        """,
    )
    
    opened by adam444555 0
  • allow empty input and return None

    allow empty input and return None

    Allow empty inputs to serializing util function. This allows reading from an API which could include empty values and still return a valid format for databases.

    opened by Philipduerholt 0
  • Column name duplicates unexpected behaviour

    Column name duplicates unexpected behaviour

    Using fetch_all() with a JOIN in the query, resulting in a result containing the same column name twice, shows only one of both resulting columns in output dictionary.

    Example:

    Two tables contain a column called name. We join both tables and the result table now has two columns called name. With fetch_all() we only get one result set for a column called name (dictionary has unique keys).

    Possible fixes:

    • Throw a warning when the result set has a duplicate column name
    • Rename columns in output dictionary when the result set has a duplicate column name
    • If possible use table alias for each of the repeated column names as prefix in output dictionary key, separated by underscore
    good first issue 
    opened by Philipduerholt 4
Releases(v0.2.0)
Owner
snapADDY GmbH
Official GitHub Organization of the snapADDY GmbH
snapADDY GmbH
Makes it easier to write raw SQL in Python.

CoolSQL Makes it easier to write raw SQL in Python. Usage Quick Start from coolsql import Field name = Field("name") age = Field("age") condition =

Aber 7 Aug 21, 2022
Making it easy to query APIs via SQL

Shillelagh Shillelagh (ʃɪˈleɪlɪ) is an implementation of the Python DB API 2.0 based on SQLite (using the APSW library): from shillelagh.backends.apsw

Beto Dealmeida 207 Dec 30, 2022
SQL queries to collections

SQC SQL Queries to Collections Examples from sqc import sqc data = [ {"a": 1, "b": 1}, {"a": 2, "b": 1}, {"a": 3, "b": 2}, ] Simple filte

Alexander Volkovsky 0 Jul 6, 2022
An extension package of 🤗 Datasets that provides support for executing arbitrary SQL queries on HF datasets

datasets_sql A ?? Datasets extension package that provides support for executing arbitrary SQL queries on HF datasets. It uses DuckDB as a SQL engine

Mario Šaško 19 Dec 15, 2022
dask-sql is a distributed SQL query engine in python using Dask

dask-sql is a distributed SQL query engine in Python. It allows you to query and transform your data using a mixture of common SQL operations and Python code and also scale up the calculation easily if you need it.

Nils Braun 271 Dec 30, 2022
Easy-to-use data handling for SQL data stores with support for implicit table creation, bulk loading, and transactions.

dataset: databases for lazy people In short, dataset makes reading and writing data in databases as simple as reading and writing JSON files. Read the

Friedrich Lindenberg 4.2k Jan 2, 2023
Python PostgreSQL adapter to stream results of multi-statement queries without a server-side cursor

streampq Stream results of multi-statement PostgreSQL queries from Python without server-side cursors. Has benefits over some other Python PostgreSQL

Department for International Trade 6 Oct 31, 2022
edaSQL is a library to link SQL to Exploratory Data Analysis and further more in the Data Engineering.

edaSQL is a python library to bridge the SQL with Exploratory Data Analysis where you can connect to the Database and insert the queries. The query results can be passed to the EDA tool which can give greater insights to the user.

Tamil Selvan 8 Dec 12, 2022
Apache Libcloud is a Python library which hides differences between different cloud provider APIs and allows you to manage different cloud resources through a unified and easy to use API

Apache Libcloud - a unified interface for the cloud Apache Libcloud is a Python library which hides differences between different cloud provider APIs

The Apache Software Foundation 1.9k Dec 25, 2022
Implementing basic MySQL CRUD (Create, Read, Update, Delete) queries, using Python.

MySQL with Python Implementing basic MySQL CRUD (Create, Read, Update, Delete) queries, using Python. We can connect to a MySQL database hosted locall

MousamSingh 5 Dec 1, 2021