flaskosql


Nameflaskosql JSON
Version 2.1.4 PyPI version JSON
download
home_page
SummaryORM to databases for FLASK API
upload_time2023-08-27 23:29:31
maintainer
docs_urlNone
authorAshraf khabar
requires_python
license
keywords python orm api oracle mysql database flask
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# FlaskoSQL



[![PyPI version](https://img.shields.io/badge/flaskos-2.1.4-green.svg)](https://pypi.org/project/flaskosql/)

[![GitHub code source](https://img.shields.io/badge/Code-Source-orange.svg)](https://github.com/Ashraf-Khabar/FLASKOSQL)

[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)







<p align="center">

 <br><br>

 <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/5/50/Oracle_logo.svg/2560px-Oracle_logo.svg.png" alt="oracle" height="20">

 <br><br>

 <img src="https://upload.wikimedia.org/wikipedia/fr/thumb/6/62/MySQL.svg/1200px-MySQL.svg.png" alt="oracle" height="50">

</p>



**NEW :** *Support MySQL DBMS.*



Description

-----------



The Package Name is a Python package that provides an Object-Relational Mapping (ORM) solution for relational databases (Oracle and MySQL), specifically designed for use in Flask APIs. It simplifies the interaction with an Oracle and MySQL database by providing an intuitive interface for querying, inserting, updating, and deleting data.



Features

--------



-   Easy integration with Flask: Seamlessly integrate the ORM into your Flask application for database operations.

-   Simplified querying: Perform complex queries using an expressive API, allowing you to focus on your application logic rather than database intricacies.

-   Model-based approach: Define your database schema using Python classes, reducing the need for manual SQL queries and keeping your code organized.

-   Transaction support: Manage database transactions easily, ensuring data consistency and integrity.



Installation

------------



You can install the Package Name package using pip:



`pip install flaskosql`



Usage

-----



1.  Import the necessary classes and functions from the package:



`from flaskosql.db import Connect`<br>

`from flaskosql.field import Field`<br>

`from flaskosql.model import Model`<br>



1.  Create a model class that represents a table in your Oracle database. Define the table schema using the `Field` class:



```py

from flaskosql.model import Model

from flaskosql.field import Field



class Roles(Model):

    ID = Field("id", "NUMBER", primary_key=True)

    NAME = Field("name", "VARCHAR2(100)", nullable=False)

```

We can use also other table to create a realtion one to many : 

```py

from flaskosql.model import Model

from flaskosql.field import Field



class Users(Model):

    ID = Field("id", "NUMBER", primary_key=True)

    NAME = Field("name", "VARCHAR2(100)", nullable=False)

    ROLE_ID = Field("role_id", "NUMBER", foreign_key=("roles", "id"))

```

We should always put the names of fileds in upercase `(it's obligatory)`

1. Create a database connection : 



```py

from flaskosql.db import Connect



connection = Connect('orm', 'ormpw', 'localhost', '1521', 'orcl').get_connection()

```



2. Initialize the database connection:



```py

from flaskosql.db import Connect

from flaskosql.model import Model



# Setup the connection : 

connection = Connect('orm', 'ormpw', 'localhost', '1521', 'orcl').get_connection()

# CReate the connection for the model  :

Model.set_connection(connection=connection)

```

1.  Perform database operations using the model:



# Creation of tables (migrations) : 

```py

def migrate():

    Roles.create_table()

    Users.create_table()



migrate()

```

We must create Roles table before Users because we already defined a `foreing_key` constraint . 



# Filter users by a condition

```py

role = Roles.get(id=1, name="ASHRAF")

```

and we can display the value :

```py

if role:

    print(f"The id :{role.ID}")

    print(f"The name : {role.NAME})

```



# Insert a new user

```py

# Creating a user:

role = Roles(id=1, name="ASHRAF")

role.save()

```



# Update a user's email

```py

role.name = "SAMI"

role.update()

```



# Delete a user

```py

role.delete()

```



For more details on using the Package Name package, please refer to the [documentation](https://achrafkhabar.com/flaskoSQL).



License

-------



This package is licensed under the MIT License. See the [LICENSE]() file for more information.



* * * * *



Feel free to modify this template according to your needs. Remember to replace "Package Name" with the actual name of your package and update the relevant sections with the appropriate details about your ORM and its usage with Flask and Oracle databases.



Make sure to also include the actual installation instructions, usage examples, and any other relevant information in your README file to provide a comprehensive guide for users of your package.


            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "flaskosql",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "python,orm,api,oracle,mysql,database,flask",
    "author": "Ashraf khabar",
    "author_email": "<khabarachraf@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/47/b4/531ec491b42b4a7e27630364e975cd60da03703dada3b86d523b9bb11f63/flaskosql-2.1.4.tar.gz",
    "platform": null,
    "description": "\n# FlaskoSQL\n\n\n\n[![PyPI version](https://img.shields.io/badge/flaskos-2.1.4-green.svg)](https://pypi.org/project/flaskosql/)\n\n[![GitHub code source](https://img.shields.io/badge/Code-Source-orange.svg)](https://github.com/Ashraf-Khabar/FLASKOSQL)\n\n[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n\n\n\n\n\n\n\n<p align=\"center\">\n\n <br><br>\n\n <img src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/5/50/Oracle_logo.svg/2560px-Oracle_logo.svg.png\" alt=\"oracle\" height=\"20\">\n\n <br><br>\n\n <img src=\"https://upload.wikimedia.org/wikipedia/fr/thumb/6/62/MySQL.svg/1200px-MySQL.svg.png\" alt=\"oracle\" height=\"50\">\n\n</p>\n\n\n\n**NEW :** *Support MySQL DBMS.*\n\n\n\nDescription\n\n-----------\n\n\n\nThe Package Name is a Python package that provides an Object-Relational Mapping (ORM) solution for relational databases (Oracle and MySQL), specifically designed for use in Flask APIs. It simplifies the interaction with an Oracle and MySQL database by providing an intuitive interface for querying, inserting, updating, and deleting data.\n\n\n\nFeatures\n\n--------\n\n\n\n-   Easy integration with Flask: Seamlessly integrate the ORM into your Flask application for database operations.\n\n-   Simplified querying: Perform complex queries using an expressive API, allowing you to focus on your application logic rather than database intricacies.\n\n-   Model-based approach: Define your database schema using Python classes, reducing the need for manual SQL queries and keeping your code organized.\n\n-   Transaction support: Manage database transactions easily, ensuring data consistency and integrity.\n\n\n\nInstallation\n\n------------\n\n\n\nYou can install the Package Name package using pip:\n\n\n\n`pip install flaskosql`\n\n\n\nUsage\n\n-----\n\n\n\n1.  Import the necessary classes and functions from the package:\n\n\n\n`from flaskosql.db import Connect`<br>\n\n`from flaskosql.field import Field`<br>\n\n`from flaskosql.model import Model`<br>\n\n\n\n1.  Create a model class that represents a table in your Oracle database. Define the table schema using the `Field` class:\n\n\n\n```py\n\nfrom flaskosql.model import Model\n\nfrom flaskosql.field import Field\n\n\n\nclass Roles(Model):\n\n    ID = Field(\"id\", \"NUMBER\", primary_key=True)\n\n    NAME = Field(\"name\", \"VARCHAR2(100)\", nullable=False)\n\n```\n\nWe can use also other table to create a realtion one to many : \n\n```py\n\nfrom flaskosql.model import Model\n\nfrom flaskosql.field import Field\n\n\n\nclass Users(Model):\n\n    ID = Field(\"id\", \"NUMBER\", primary_key=True)\n\n    NAME = Field(\"name\", \"VARCHAR2(100)\", nullable=False)\n\n    ROLE_ID = Field(\"role_id\", \"NUMBER\", foreign_key=(\"roles\", \"id\"))\n\n```\n\nWe should always put the names of fileds in upercase `(it's obligatory)`\n\n1. Create a database connection : \n\n\n\n```py\n\nfrom flaskosql.db import Connect\n\n\n\nconnection = Connect('orm', 'ormpw', 'localhost', '1521', 'orcl').get_connection()\n\n```\n\n\n\n2. Initialize the database connection:\n\n\n\n```py\n\nfrom flaskosql.db import Connect\n\nfrom flaskosql.model import Model\n\n\n\n# Setup the connection : \n\nconnection = Connect('orm', 'ormpw', 'localhost', '1521', 'orcl').get_connection()\n\n# CReate the connection for the model  :\n\nModel.set_connection(connection=connection)\n\n```\n\n1.  Perform database operations using the model:\n\n\n\n# Creation of tables (migrations) : \n\n```py\n\ndef migrate():\n\n    Roles.create_table()\n\n    Users.create_table()\n\n\n\nmigrate()\n\n```\n\nWe must create Roles table before Users because we already defined a `foreing_key` constraint . \n\n\n\n# Filter users by a condition\n\n```py\n\nrole = Roles.get(id=1, name=\"ASHRAF\")\n\n```\n\nand we can display the value :\n\n```py\n\nif role:\n\n    print(f\"The id :{role.ID}\")\n\n    print(f\"The name : {role.NAME})\n\n```\n\n\n\n# Insert a new user\n\n```py\n\n# Creating a user:\n\nrole = Roles(id=1, name=\"ASHRAF\")\n\nrole.save()\n\n```\n\n\n\n# Update a user's email\n\n```py\n\nrole.name = \"SAMI\"\n\nrole.update()\n\n```\n\n\n\n# Delete a user\n\n```py\n\nrole.delete()\n\n```\n\n\n\nFor more details on using the Package Name package, please refer to the [documentation](https://achrafkhabar.com/flaskoSQL).\n\n\n\nLicense\n\n-------\n\n\n\nThis package is licensed under the MIT License. See the [LICENSE]() file for more information.\n\n\n\n* * * * *\n\n\n\nFeel free to modify this template according to your needs. Remember to replace \"Package Name\" with the actual name of your package and update the relevant sections with the appropriate details about your ORM and its usage with Flask and Oracle databases.\n\n\n\nMake sure to also include the actual installation instructions, usage examples, and any other relevant information in your README file to provide a comprehensive guide for users of your package.\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "ORM to databases for FLASK API",
    "version": "2.1.4",
    "project_urls": null,
    "split_keywords": [
        "python",
        "orm",
        "api",
        "oracle",
        "mysql",
        "database",
        "flask"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "13007d7f8a88b35cb33384a0800251ef27be928cbd12d42a2464121907fd2049",
                "md5": "a50736ed0ea7ee2455bfc8ac67b71de2",
                "sha256": "9f2ef430711e680f08a483005946e84a7bfdeffb4ae16912374f1794a924b23e"
            },
            "downloads": -1,
            "filename": "flaskosql-2.1.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a50736ed0ea7ee2455bfc8ac67b71de2",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 8047,
            "upload_time": "2023-08-27T23:29:29",
            "upload_time_iso_8601": "2023-08-27T23:29:29.034549Z",
            "url": "https://files.pythonhosted.org/packages/13/00/7d7f8a88b35cb33384a0800251ef27be928cbd12d42a2464121907fd2049/flaskosql-2.1.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "47b4531ec491b42b4a7e27630364e975cd60da03703dada3b86d523b9bb11f63",
                "md5": "fbf792ebabd942cd1d5614afa46f6b3f",
                "sha256": "53be3b6cfa5065975c9614366e12daaa7ef3d31d4f58cf23ddad1f546ba4e07f"
            },
            "downloads": -1,
            "filename": "flaskosql-2.1.4.tar.gz",
            "has_sig": false,
            "md5_digest": "fbf792ebabd942cd1d5614afa46f6b3f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 9620,
            "upload_time": "2023-08-27T23:29:31",
            "upload_time_iso_8601": "2023-08-27T23:29:31.656795Z",
            "url": "https://files.pythonhosted.org/packages/47/b4/531ec491b42b4a7e27630364e975cd60da03703dada3b86d523b9bb11f63/flaskosql-2.1.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-27 23:29:31",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "flaskosql"
}
        
Elapsed time: 0.13153s