哈迪資料庫
HadiDB 是一個用 Python 寫的輕量級、高度程度可擴充的資料庫。
如何安裝哈迪資料庫
pip install hadidb
建立用戶HadiDB
使用 createUser() 建立一個具有範例使用者名稱 admin 和範例密碼 admin 的新使用者。然後它透過呼叫authentication()方法來驗證同一用戶。
from HadiDB.operation import User user = User("admin", "admin") user.createUser() # Creating a new user in the HadiDB user.authentication() # Authenticating the HadiDB user
結果:
{'status': 200, 'message': 'Database user Created'}
建立資料庫、集合和模式
此程式碼設定使用者憑證和資料庫集合的架構。它使用具有指定使用者名稱、密碼、資料庫和集合的操作類別來初始化資料庫操作。最後,它將提供的資料插入集合中並儲存結果。
from HadiDB.operation import Operation username = "admin" password = "admin" database = "mefiz.com" collection = "authUser" schema = { "username":"Unique", "password":"Hash", "cnic":"Unique", "picture":"Image", "bio":"Text" } db = Operation(username,password,database,collection) db.create_database(schema)
插入數據
將資料插入集合中使用 db.insert(data) 將資料插入指定的資料庫集合中。
from HadiDB.operation import Operation username = "admin" password = "admin" database = "mefiz.com" collection = "authUser" db = Operation(username,password,database,collection) data = { "username":"hadidb", "password":"12345", "cnic":"123232442", "picture":"user/my/hadidb.jpg", "bio":"HadiDB is the Best ;)" } result = db.insert(data) print(result)
結果:
{ 'status': 200, 'message': 'Data insert successfully', 'data': { 'username': 'hadidb', 'password': '12345', 'cnic': '123232442', 'picture': 'user/my/hadidb.jpg', 'bio': 'HadiDB is the Best ;)', 'id': 1 } }
更新數據
更新資料 db.update(1, update_data) 使用提供的 update_data 更新資料庫中 ID 為 1 的記錄。
from HadiDB.operation import Operation username = "admin" password = "admin" database = "mefiz.com" collection = "authUser" db = Operation(username,password,database,collection) update_data = { "username": "hadidb_update", "password": "123455", "cnic": "1232324423", "picture": "user/my/hadidb1.jpg", "bio": "HadiDB is the Best ;) update bio" } result = db.update(1,update_data) print(result)
結果:
{ 'status': 200, 'message': 'Data Update successfully', 'data': { 'username': 'hadidb_update', 'password': '123455', 'cnic': '1232324423', 'picture': 'user/my/hadidb1.jpg', 'bio': 'HadiDB is the Best ;) update bio', 'id': 1 } }
按ID獲取
要檢索特定物件的文件的唯一識別碼 (ID),如果文件不存在,則發生錯誤。
result = db.getbyID(1) print(result)
取得所有對象
getAll 方法從資料庫中指定的集合中檢索所有文件。
result = db.getAll() print(result)
按鍵獲取
getbykey 方法從資料庫中檢索指定鍵值對匹配的所有文件。不支援多鍵值對
result = db.getbykey({ "username":"momin" }) print(result)
按鍵獲取
getbykeys 函數使用隱式 AND (&&) 運算。兩個條件範例(cnic 和 bio)如果符合資料庫中的鍵值,則傳回符合的物件。
result = db.getbykeys({ "cnic":"123232442", "bio":"HadiDB is the Best ;) update bio" }) print(result)
數數
count 方法傳回資料庫中指定集合中存在的文件(或物件)總數。
result = db.count() print(result)
結果:
{'status': 200, 'count': 1}
Gey按鍵計數
getbykeyCount 方法統計集合中指定鍵值對符合的文件數量。
result = db.getbykeyCount({ "username":"momin" })
刪除
透過唯一識別碼 (id) 從資料庫中刪除文件
result = db.delete(1) print(result)
結果:
{'status': 200, 'message': 'data delete successful'}
取得所有資料庫
使用Configuration類別的get_database()方法檢索所有可用的資料庫
pip install hadidb
取得所有收藏
使用 Configuration 類別的 get_collection() 方法從特定資料庫檢索所有集合。
from HadiDB.operation import User user = User("admin", "admin") user.createUser() # Creating a new user in the HadiDB user.authentication() # Authenticating the HadiDB user
取得特定集合的模式
使用 Configuration 類別中的 get_schema() 方法傳回特定集合的 Schema。
{'status': 200, 'message': 'Database user Created'}
刪除集合
使用DatabaseDeletionService 類別的deleteCollection() 方法從資料庫中刪除特定集合。
from HadiDB.operation import Operation username = "admin" password = "admin" database = "mefiz.com" collection = "authUser" schema = { "username":"Unique", "password":"Hash", "cnic":"Unique", "picture":"Image", "bio":"Text" } db = Operation(username,password,database,collection) db.create_database(schema)
刪除資料庫
使用DatabaseDeletionService類別的deleteDatabase()方法刪除資料庫。
from HadiDB.operation import Operation username = "admin" password = "admin" database = "mefiz.com" collection = "authUser" db = Operation(username,password,database,collection) data = { "username":"hadidb", "password":"12345", "cnic":"123232442", "picture":"user/my/hadidb.jpg", "bio":"HadiDB is the Best ;)" } result = db.insert(data) print(result)
GitHub:https://github.com/MominIqbal-1234/hadidb
檢查網址:https://mefiz.com
開發者:莫明·伊克巴爾
以上是HadiDB:Python 中的輕量級、可水平擴展的資料庫的詳細內容。更多資訊請關注PHP中文網其他相關文章!

MySQL在Web應用中的主要作用是存儲和管理數據。 1.MySQL高效處理用戶信息、產品目錄和交易記錄等數據。 2.通過SQL查詢,開發者能從數據庫提取信息生成動態內容。 3.MySQL基於客戶端-服務器模型工作,確保查詢速度可接受。

構建MySQL數據庫的步驟包括:1.創建數據庫和表,2.插入數據,3.進行查詢。首先,使用CREATEDATABASE和CREATETABLE語句創建數據庫和表,然後用INSERTINTO語句插入數據,最後用SELECT語句查詢數據。

MySQL適合初學者,因為它易用且功能強大。 1.MySQL是關係型數據庫,使用SQL進行CRUD操作。 2.安裝簡單,需配置root用戶密碼。 3.使用INSERT、UPDATE、DELETE、SELECT進行數據操作。 4.複雜查詢可使用ORDERBY、WHERE和JOIN。 5.調試需檢查語法,使用EXPLAIN分析查詢。 6.優化建議包括使用索引、選擇合適數據類型和良好編程習慣。

MySQL適合初學者,因為:1)易於安裝和配置,2)有豐富的學習資源,3)SQL語法直觀,4)工具支持強大。儘管如此,初學者需克服數據庫設計、查詢優化、安全管理和數據備份等挑戰。

是的,sqlisaprogramminglanguges pecialized fordatamanage.1)它具有焦點,focusingonwhattoachieveratherthanhow.2)sqlisessential forquerying forquerying,插入,更新,更新,和detletingdatainrelationalDatabases.3)

ACID屬性包括原子性、一致性、隔離性和持久性,是數據庫設計的基石。 1.原子性確保事務要么完全成功,要么完全失敗。 2.一致性保證數據庫在事務前後保持一致狀態。 3.隔離性確保事務之間互不干擾。 4.持久性確保事務提交後數據永久保存。

MySQL既是數據庫管理系統(DBMS),也與編程語言緊密相關。 1)作為DBMS,MySQL用於存儲、組織和檢索數據,優化索引可提高查詢性能。 2)通過SQL與編程語言結合,嵌入在如Python中,使用ORM工具如SQLAlchemy可簡化操作。 3)性能優化包括索引、查詢、緩存、分庫分錶和事務管理。

MySQL使用SQL命令管理數據。 1.基本命令包括SELECT、INSERT、UPDATE和DELETE。 2.高級用法涉及JOIN、子查詢和聚合函數。 3.常見錯誤有語法、邏輯和性能問題。 4.優化技巧包括使用索引、避免SELECT*和使用LIMIT。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

Atom編輯器mac版下載
最受歡迎的的開源編輯器

PhpStorm Mac 版本
最新(2018.2.1 )專業的PHP整合開發工具

禪工作室 13.0.1
強大的PHP整合開發環境

WebStorm Mac版
好用的JavaScript開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)