{"id":19617724,"url":"https://github.com/macagua/example.flask.crud-app","last_synced_at":"2025-04-28T02:32:07.290Z","repository":{"id":53664110,"uuid":"150727611","full_name":"macagua/example.flask.crud-app","owner":"macagua","description":"Building a CRUD application with Flask and SQLAlchemy","archived":false,"fork":false,"pushed_at":"2025-03-07T11:28:18.000Z","size":105,"stargazers_count":13,"open_issues_count":0,"forks_count":10,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-05T05:33:12.346Z","etag":null,"topics":["flask","flask-application","flask-sqlalchemy","flask-web","python3"],"latest_commit_sha":null,"homepage":"https://www.codementor.io/@garethdwyer/building-a-crud-application-with-flask-and-sqlalchemy-dm3wv7yu2","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/macagua.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-09-28T11:02:44.000Z","updated_at":"2025-03-07T11:28:18.000Z","dependencies_parsed_at":"2025-02-21T08:23:34.138Z","dependency_job_id":"6b8b50bb-d674-408c-a201-dbbe3c398b95","html_url":"https://github.com/macagua/example.flask.crud-app","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/macagua%2Fexample.flask.crud-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/macagua%2Fexample.flask.crud-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/macagua%2Fexample.flask.crud-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/macagua%2Fexample.flask.crud-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/macagua","download_url":"https://codeload.github.com/macagua/example.flask.crud-app/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251238216,"owners_count":21557419,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flask","flask-application","flask-sqlalchemy","flask-web","python3"],"created_at":"2024-11-11T11:06:48.810Z","updated_at":"2025-04-28T02:32:07.280Z","avatar_url":"https://github.com/macagua.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"======================\nexample.flask.crud-app\n======================\n\n.. image:: https://raw.githubusercontent.com/macagua/example.flask.crud-app/master/docs/_static/flask-vertical.png\n   :class: image-inline\n\nBuilding a CRUD application with Flask and SQLAlchemy\n\n\nRequirements\n============\n\nPlease execute the following commands:\n\n::\n\n    $ sudo apt install -y python3-dev python3-pip python3-virtualenv\n    $ sudo apt install -y git\n    $ sudo apt install -y sqlite3\n    $ git clone https://github.com/macagua/example.flask.crud-app.git flask-crud-app\n    $ cd ./flask-crud-app\n    $ virtualenv --python /usr/bin/python3 venv\n    $ source ./venv/bin/activate\n    $ pip3 install -U pip\n    $ pip3 install -r requirements.txt\n\n\n----\n\nRunning\n=======\n\nPlease execute the following command:\n\n::\n\n    $ python3 bookmanager.py\n\nOpen at your Web browser the following link http://127.0.0.1:5000/\n\n.. image:: https://raw.githubusercontent.com/macagua/example.flask.crud-app/master/docs/_static/bookmanager.png\n   :class: image-inline\n\nDisplay a **Book Manager** app, like the previous figure.\n\n\n----\n\nSQLAlchemy to SQL\n=================\n\nThe following code is an example of how SQLAlchemy translates\nthe Python code to SQL code.\n\n**db.session.commit()**\n\nInsert the following books into the database:\n\n::\n\n\n    INSERT INTO book (title) VALUES ('The Hobbie');\n    INSERT INTO book (title) VALUES ('The Lord of Rings');\n    INSERT INTO book (title) VALUES ('The Silmarillion');\n    INSERT INTO book (title) VALUES ('The Children of Húrin');\n    COMMIT;\n\n----\n\nUpdate the title of the book 'The Lord of Rings' to 'The Lord of the Rings':\n\n::\n\n\n    UPDATE book\n    SET title='The Lord of the Rings'\n    WHERE title = 'The Lord of Rings';\n    COMMIT;\n\n----\n\n**Book.query.all()**\n\nSearch for all books:\n\n::\n\n\n    SELECT * FROM book;\n\n**Book.query.filter_by(title=old_title).first()**:\n\nSearch for the book with the title 'The Hobbie':\n\n::\n\n\n    SELECT book.title\n    FROM book\n    WHERE book.title = 'The Hobbie'\n    LIMIT 1 OFFSET 0;\n\n----\n\n**db.session.delete(book)**:\n\nDelete the book with the title 'The Children of Húrin':\n\n::\n\n\n    DELETE FROM book\n    WHERE book.title = 'The Children of Húrin';\n\n\n----\n\n\nLicense\n========\n\nThis project is licensed under the MIT License - see the `LICENSE \u003c./LICENSE\u003e`_ file for details.\n\n\n----\n\n\nReferences\n==========\n\n- `Building a CRUD application with Flask and SQLAlchemy \u003chttps://www.codementor.io/@garethdwyer/building-a-crud-application-with-flask-and-sqlalchemy-dm3wv7yu2\u003e`_.\n- `SQLAlchemy Unified Tutorial \u003chttps://docs.sqlalchemy.org/en/20/tutorial/index.html#unified-tutorial\u003e`_.\n- `Modifying and Querying Data — Flask-SQLAlchemy Documentation \u003chttps://flask-sqlalchemy.palletsprojects.com/en/stable/queries/\u003e`_.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmacagua%2Fexample.flask.crud-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmacagua%2Fexample.flask.crud-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmacagua%2Fexample.flask.crud-app/lists"}