DBGenieは、MongoDB、PostgreSQL、およびMySQLデータベースのデータベース操作を自動化するためのクラスを提供するPythonパッケージです。このパッケージは、一般的なデータベース操作をカプセル化する使いやすいクラスを提供し、開発者が低レベルのデータベースインタラクションを扱うのではなく、アプリケーションの構築に集中できるようにします。
PIPを使用してDBGenieをインストールできます。
pip install dbgenie2複数のデータベースのサポート:DBGenieはMongoDB、PostgreSQL、およびMySQLデータベースをサポートしており、さまざまなデータベースシステム全体のCRUD操作の統一インターフェイスを提供します。
シンプルで直感的なAPI:パッケージは、CRUD操作を実行するための簡単なAPIを提供し、開発者が複雑なSQLクエリまたはMongoDBコマンドを作成する必要なくデータベースと簡単に対話できるようにします。
自動接続管理:データベースへの接続、クエリの実行、接続の閉鎖、効率的なリソースの使用の確保、メモリリークの防止など、データベース接続接続管理を処理します。
柔軟性と拡張可能:このパッケージは、柔軟性と拡張可能になるように設計されており、開発者は特定のユースケースに必要に応じて機能をカスタマイズおよび拡張できるようにします。
DBGenieは、サポートされているデータベースシステムごとに個別のクラスを提供します。
各クラスは、以下を含む、それぞれのデータベースシステムの一般的なCRUD操作をカプセル化します。
開発者は、これらのクラスをインスタンス化し、接続パラメーターを構成し、提供されたメソッドを使用してデータベースとシームレスに対話できます。
from dbgenie.mongodb.mongocrud import MongoDBCrud
# Connect to MongoDB
mongodb_crud = MongoDBCrud(uri= " mongodb://localhost:27017 " , database= " my_database " , collection= " my_collection " )
# Insert document
mongodb_crud.insert_document({ " name " : " John " , " age " : 30})
# Find document
document = mongodb_crud.find_document({ " name " : " John " })
print(document)
# Update document
mongodb_crud.update_document({ " name " : " John " }, { " age " : 35})
# Delete document
mongodb_crud.delete_document({ " name " : " John " })from dbgenie.postgresql.postgrescrud import PostgreSQLCrud
# Connect to PostgreSQL
postgresql_crud = PostgreSQLCrud(host= " localhost " , user= " postgres " , password= " password " , database= " my_database " )
# Create table
postgresql_crud.create_table( " my_table " , [ " id SERIAL PRIMARY KEY " , " name VARCHAR(255) " , " age INT " ])
# Insert record
postgresql_crud.insert_record( " my_table " , (1, " John " , 30))
# Read records
records = postgresql_crud.read_records( " my_table " )
print(records)
# Update record
postgresql_crud.update_record( " my_table " , { " age " : 35}, " name='John' " )
# Delete record
postgresql_crud.delete_record( " my_table " , " name='John' " )from dbgenie.mysql.mysqlcrud import MySQLCrud
# Connect to MySQL
mysql_crud = MySQLCrud(host= " localhost " , user= " root " , password= " password " , database= " my_database " )
# Create table
mysql_crud.create_table( " my_table " , [ " id INT AUTO_INCREMENT PRIMARY KEY " , " name VARCHAR(255) " , " age INT " ])
# Insert record
mysql_crud.insert_record( " my_table " , (1, " John " , 30))
# Read records
records = mysql_crud.read_records( " my_table " )
print(records)
# Update record
mysql_crud.update_record( " my_table " , { " age " : 35}, " name='John' " )
# Delete record
mysql_crud.delete_record( " my_table " , " name='John' " )DBGenieへの貢献は大歓迎です!新機能、改善、またはバグの修正に関するアイデアがある場合は、お気軽に問題を開いたり、プルリクエストを送信したりしてください。詳細については、貢献ガイドラインを参照してください。
DBGenieはMITライセンスの下でライセンスされています。詳細については、ライセンスファイルを参照してください。