raw-database


Nameraw-database JSON
Version 0.0.4 PyPI version JSON
download
home_page
SummarySimple Module Using Raw SQL To Get Insert Update Database
upload_time2023-10-10 11:22:56
maintainer
docs_urlNone
authorTriNguyen
requires_python
license
keywords python database raw database postgrest mysql
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# Simple Module For Database

This is a simple Python module that provides functions to perform basic insert, update, and delete actions on a database.

## Installation

To use this module, you need to have Python installed on your system. You can install the module using pip:

```shell
pip install raw-database
```

## Usage
###### Import the module into your Python script:

    from raw_database import Insert, Update, QuerySet

## Insert Action
    
    Insert(connection, is_commit=False).into(table).values(**values).returning(return_key).fetchone()

* connection: Connection to database
* is_commit: Determine whether to commit this data
* table: The name of the table where the data will be inserted.
* values: A dictionary containing the data to be inserted, with column names as keys and corresponding values.
* return_key: A key will be return if insert is success

### Example usage:

    Insert(connection_, is_commit=False).into("accounts").values(user_id=6, username="Tom B", email="test email").returning("user_id").fetchone()

## Update Action

    Update(connection, is_commit=False)(table).set(**values).where(**conditions).returning(return_key).fetchone()

* connection: Connection to database
* is_commit: Determine whether to commit this data
* table: The name of the table where the data will be inserted.
* values: A dictionary containing the data to be inserted, with column names as keys and corresponding values.
* conditions: A dictionary containing conditions to update
* return_key: A key will be return if insert is success

### Example usage:

    Update(connection_, is_commit=False)(table="accounts").set(email="test email update", username="test username update").where(user_id=1).returning("user_id").fetchone()

## Get Action

    QuerySet(connection).select(*fields).from_(table).where(**condition).fetchone()

* connection: Connection to database
* fields: A list containing the selected from table
* table: The name of the table where the data will be inserted.
* conditions: A dictionary containing conditions to update

### Example usage:
    
    QuerySet(connection_).select("user_id", "username").from_("accounts").where(user_id=1).fetchone()
    QuerySet(connection_).select().from_("accounts").fetchall()
    QuerySet(connection_).select().from_("accounts").limit(2).fetchall()
    QuerySet(connection_).select().from_("accounts").order_by("user_id DESC").fetchall()
    QuerySet(connection_).select("user_id").from_("accounts").where(user_id__in=(1, 2, 3), username='Tom B. Erichsen').fetchall()
    QuerySet(connection_).select("user_id").from_("accounts").where(user_id__in=(1, 2, 3)).fetchall()
    QuerySet(connection_).select("password", "COUNT(*) AS same_password").from_("accounts").where(user_id__in=(1, 2, 3, 4)).group_by("password").fetchall()
    

# Contributing
###### Contributions are welcome! If you'd like to contribute to this module, please follow these steps:
* Fork the repository at [GitHub](https://github.com/trinct1412/raw_database).
* Create a new branch for your feature/bug fix.
* Make your changes and commit them.
* Push your changes to your fork.
* Submit a pull request.




            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "raw-database",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "python,database,raw database,postgrest,mysql",
    "author": "TriNguyen",
    "author_email": "<trinct1412@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/02/92/19a41eb8981d8ef9afdd977a9f03a134e6692ba100dd72bb1f0a1d81f03e/raw_database-0.0.4.tar.gz",
    "platform": null,
    "description": "\n# Simple Module For Database\n\nThis is a simple Python module that provides functions to perform basic insert, update, and delete actions on a database.\n\n## Installation\n\nTo use this module, you need to have Python installed on your system. You can install the module using pip:\n\n```shell\npip install raw-database\n```\n\n## Usage\n###### Import the module into your Python script:\n\n    from raw_database import Insert, Update, QuerySet\n\n## Insert Action\n    \n    Insert(connection, is_commit=False).into(table).values(**values).returning(return_key).fetchone()\n\n* connection: Connection to database\n* is_commit: Determine whether to commit this data\n* table: The name of the table where the data will be inserted.\n* values: A dictionary containing the data to be inserted, with column names as keys and corresponding values.\n* return_key: A key will be return if insert is success\n\n### Example usage:\n\n    Insert(connection_, is_commit=False).into(\"accounts\").values(user_id=6, username=\"Tom B\", email=\"test email\").returning(\"user_id\").fetchone()\n\n## Update Action\n\n    Update(connection, is_commit=False)(table).set(**values).where(**conditions).returning(return_key).fetchone()\n\n* connection: Connection to database\n* is_commit: Determine whether to commit this data\n* table: The name of the table where the data will be inserted.\n* values: A dictionary containing the data to be inserted, with column names as keys and corresponding values.\n* conditions: A dictionary containing conditions to update\n* return_key: A key will be return if insert is success\n\n### Example usage:\n\n    Update(connection_, is_commit=False)(table=\"accounts\").set(email=\"test email update\", username=\"test username update\").where(user_id=1).returning(\"user_id\").fetchone()\n\n## Get Action\n\n    QuerySet(connection).select(*fields).from_(table).where(**condition).fetchone()\n\n* connection: Connection to database\n* fields: A list containing the selected from table\n* table: The name of the table where the data will be inserted.\n* conditions: A dictionary containing conditions to update\n\n### Example usage:\n    \n    QuerySet(connection_).select(\"user_id\", \"username\").from_(\"accounts\").where(user_id=1).fetchone()\n    QuerySet(connection_).select().from_(\"accounts\").fetchall()\n    QuerySet(connection_).select().from_(\"accounts\").limit(2).fetchall()\n    QuerySet(connection_).select().from_(\"accounts\").order_by(\"user_id DESC\").fetchall()\n    QuerySet(connection_).select(\"user_id\").from_(\"accounts\").where(user_id__in=(1, 2, 3), username='Tom B. Erichsen').fetchall()\n    QuerySet(connection_).select(\"user_id\").from_(\"accounts\").where(user_id__in=(1, 2, 3)).fetchall()\n    QuerySet(connection_).select(\"password\", \"COUNT(*) AS same_password\").from_(\"accounts\").where(user_id__in=(1, 2, 3, 4)).group_by(\"password\").fetchall()\n    \n\n# Contributing\n###### Contributions are welcome! If you'd like to contribute to this module, please follow these steps:\n* Fork the repository at [GitHub](https://github.com/trinct1412/raw_database).\n* Create a new branch for your feature/bug fix.\n* Make your changes and commit them.\n* Push your changes to your fork.\n* Submit a pull request.\n\n\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Simple Module Using Raw SQL To Get Insert Update Database",
    "version": "0.0.4",
    "project_urls": null,
    "split_keywords": [
        "python",
        "database",
        "raw database",
        "postgrest",
        "mysql"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e0b0f2032f09a80c707527742cc88068b0ef6a1e4fd02e37bb1784a71c367b73",
                "md5": "eb73a049261d90cc3532a4a7d17c2288",
                "sha256": "b138b1fc983b93b7e517556fec8fa02443b078e57b6fde394b8b3e0e62fbc376"
            },
            "downloads": -1,
            "filename": "raw_database-0.0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "eb73a049261d90cc3532a4a7d17c2288",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 6671,
            "upload_time": "2023-10-10T11:22:54",
            "upload_time_iso_8601": "2023-10-10T11:22:54.358178Z",
            "url": "https://files.pythonhosted.org/packages/e0/b0/f2032f09a80c707527742cc88068b0ef6a1e4fd02e37bb1784a71c367b73/raw_database-0.0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "029219a41eb8981d8ef9afdd977a9f03a134e6692ba100dd72bb1f0a1d81f03e",
                "md5": "814ecb0f9ba629c4034fbc7bce8ec425",
                "sha256": "b0c8e4d8e09b66f0bfd74bab75eb483b8d4a7a145d0646577680f0892e943a38"
            },
            "downloads": -1,
            "filename": "raw_database-0.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "814ecb0f9ba629c4034fbc7bce8ec425",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 4566,
            "upload_time": "2023-10-10T11:22:56",
            "upload_time_iso_8601": "2023-10-10T11:22:56.873026Z",
            "url": "https://files.pythonhosted.org/packages/02/92/19a41eb8981d8ef9afdd977a9f03a134e6692ba100dd72bb1f0a1d81f03e/raw_database-0.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-10 11:22:56",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "raw-database"
}
        
Elapsed time: 0.12158s