Commit acb1a6e4 authored by vipul.v's avatar vipul.v

first

parents
# Default ignored files
/shelf/
/workspace.xml
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (ApiTest)" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/ApiTest.iml" filepath="$PROJECT_DIR$/.idea/ApiTest.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
import uvicorn
from script.core.engine.mongo_connection import get_database
if __name__ == "__main__":
get_database()
uvicorn.run("script.service.fastapi_calls:app")
from pymongo import MongoClient
def get_database():
uri = "mongodb://intern_23:intern%40123@192.168.0.220:2717/?serverSelectionTimeoutMS=5000&connectTimeoutMS=10000&authSource=interns_b2_23&authMechanism=SCRAM-SHA-256"
client = MongoClient(uri)
return client['interns_b2_23']
dbname = get_database()
inventory = dbname["Vipul-inventory"]
from script.core.engine.mongo_connection import inventory
inven_tory5 = {
"order_id": "8",
"date": "13/05/2022",
"customer_name": "karun",
"status": "not active",
"sales_order": 90
}
def insert_one():
inventory.insert_one(inven_tory5)
return inven_tory5
def update_data():
inventory.update_one({"customer_name": "Akul"}, {"$set": {"customer_name": "vijay"}})
def delete_data():
inventory.delete_one({"order_id": "1"})
def find_data():
inventory.delete_one({"order_id": "1"})
from fastapi import FastAPI
from script.core.handlers.CRUD_operations import insert_one, update_data, delete_data, find_data
app = FastAPI()
@app.get("/insert")
async def insert_data():
data = insert_one()
print(data)
return "inserted"
@app.get("/update")
async def update_file():
data = update_data()
print(data)
return "update"
@app.get("/delete")
async def delete_file():
data = delete_data()
print(data)
return "delete"
@app.get("/find")
async def find():
data = find_data()
print(data)
return "found"
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment