We also do not have links that lead to sites DMCA copyright infringement. If You feel that this book is belong to you and you want to unpublish it, Please Contact us.
Essentials of Medical Microbiology 2nd Edition. Download e-Book. Posted on. Page Count. Download e-Book Pdf. Related e-Books. There's also live online events, interactive content, certification prep materials, and more.
SQLAlchemy is a library used to interact with a wide variety of databases. It enables you to create data models and queries in a manner that feels like normal Python classes and statements. Created by Mike Bayer in , SQLAlchemy is used by many companies great and small, and is considered by many to be the de facto way of working with relational databases in Python. It also provides a way to add support for other relational databases as well. Amazon Redshift, which uses a custom dialect of PostgreSQL, is a great example of database support added by the community.
SQLAlchemy leverages powerful common statements and types to ensure its SQL statements are crafted efficiently and properly for each database type and vendor without you having to think about it. This makes it easy to migrate logic from Oracle to PostgreSQL or from an application database to a data warehouse. It also helps ensure that database input is sanitized and properly escaped prior to being submitted to the database. This prevents common issues like SQL injection attacks.
These modes can be used separately or together depending on your preference and the needs of your application. It is focused on the actual database schema; however, it is standardized in such a way that it provides a consistent language across a large number of backend databases.
It is focused around the domain model of the application and leverages the Unit of Work pattern to maintain object state. It also provides a high-level abstraction on top of the SQL Expression Language that enables the user to work in a more idiomatic way. While the ORM is extremely useful, you must keep in mind that there is a difference between the way classes can be related, and how the underlying database relationships work.
The choice of using SQLAlchemy Core or ORM as the dominant data access layer for an application often comes down to a few factors and personal preference. The two modes use slightly different syntax, but the biggest difference between Core and ORM is the view of data as schema or business objects.
SQLAlchemy Core really shines in data warehouse, reporting, analysis, and other scenarios where being able to tightly control the query or operating on unmodeled data is useful. The strong database connection pool and result-set optimizations are perfectly suited to dealing with large amounts of data, even in multiple databases.
However, if you intend to focus more on a domain-driven design, the ORM will encapsulate much of the underlying schema and structure in metadata and business objects. This encapsulation can make it easy to make database interactions feel more like normal Python code.
Most common applications lend themselves to being modeled in this way. It can also be a highly effective way to inject domain-driven design into a legacy application or one with raw SQL statements sprinkled throughout. Microservices also benefit from the abstraction of the underlying database, allowing the developer to focus on just the process being implemented. This makes it a wonderful compliment to the ORM when you need to combine business objects and warehoused data.
If you are working with a framework that already has an ORM built in, but want to add more powerful reporting, use Core. If you have a combination of needs that really could leverage both business objects and other data unrelated to the problem domain, use both! SQLAlchemy can be used with Python 2. I recommend using pip to perform the install with the command pip install sqlalchemy. During the install, SQLAlchemy will attempt to build some C extensions, which are leveraged to make working with result sets fast and more memory efficient.
Note that using SQLAlchemy without C extensions will adversely affect performance, and you should test your code on a system with the C extensions prior to optimizing it. These DBAPIs provide the basis for the dialect each database server speaks, and often enable the unique features seen in different database servers and versions.
0コメント