版本:1.1.0b2 |发布日期:2016年7月1日

SQLAlchemy 1.1文档

0.2 Changelog

0.2.8 ¶ T0>

发布日期:2006年9月5日
  • cleanup on connection methods + documentation. 查询字符串中指定的自定义DBAPI参数,'create_engine'中的'connect_args'参数或通过'creator'函数创建自定义函数到'create_engine'。

  • added “recycle” argument to Pool, is “pool_recycle” on create_engine, defaults to 3600 seconds; connections after this age will be closed and replaced with a new one, to handle db’s that automatically close stale connections

    参考文献:#274

  • 用连接池改变了“invalidate”语义;将指示底层连接记录重新连接下次调用。如果在对connection.cursor()的底层调用中发生任何错误,“invalidate”也将自动被调用。这将希望允许连接池重新连接到已经停止并启动而不重新启动连接应用程序的数据库。

    参考文献:#121

  • eesh!教程doctest被打破了一段时间。

  • add_property() method on mapper does a “compile all mappers” step in case the given property references a non-compiled mapper (as it did in the case of the tutorial !)

  • 在创建之前检查已经存在的pg序列

    参考文献:#277

  • if a contextual session is established via MapperExtension.get_session (as it is using the sessioncontext plugin, etc), a lazy load operation will use that session by default if the parent object is not persistent with a session already.

  • 对于没有数据库标识的对象,惰性加载不会触发(为什么?请参阅http://www.sqlalchemy.org/trac/wiki/WhyDontForeignKeysLoadData

  • unit-of-work does a better check for “orphaned” objects that are part of a “delete-orphan” cascade, for certain conditions where the parent isn’t available to cascade from.

  • mappers can tell if one of their objects is an “orphan” based on interactions with the attribute package. 这个检查是基于当对象被连接和分离时为每个关系维护的一个状态标志。

  • 现在用“delete-orphan”声明一个自引用关系是无效的(因为上面的检查会使他们无法保存)

  • improved the check for objects being part of a session when the unit of work seeks to flush() them as part of a relationship..

  • statement execution supports using the same BindParam object more than once in an expression; simplified handling of positional parameters. 比尔·诺恩(Bill Noon)搞清楚了这个基本思想的好工作。

    参考文献:#280

  • postgres reflection moved to use pg_schema tables, can be overridden with use_information_schema=True argument to create_engine.

    References: #60, #71

  • added case_sensitive argument to MetaData, Table, Column, determines itself automatically based on if a parent schemaitem has a non-None setting for the flag, or if not, then whether the identifier name is all lower case or not. 当设置为True时,引用应用于具有混合或大写标识符的标识符。引用也被自动应用于已知为保留字或包含其他非标准字符的标识符。各种数据库方言可以覆盖所有这些行为,但目前他们都使用默认行为。用postgres,mysql,sqlite,oracle进行测试。需要用firebird,ms-sql进行更多的测试。正在进行的工作的一部分

    参考文献:#155

  • 单元测试更新为在没有安装任何pysqlite的情况下运行;池测试使用模拟DBAPI

  • 网址支持密码中的转义字符

    参考文献:#281

  • added limit/offset to UNION queries (though not yet in oracle)

  • 在DateTime和Time类型中添加了“timezone = True”标志。到目前为止,postgres会将其转换为“TIME [STAMP](WITH | WITHOUT)TIME ZONE”,以便对时区存在的控制更加可控(psycopg2返回带有tzinfo的datetimes(如果可用的话, ¶ T0>

  • 修复了使用具有不同的**的query.count(),具有SelectResults的** kwargs count()

    参考文献:#287

  • 当自动载入失败时,从元数据取消注册表;

    参考文献:#289

  • 导入py2.5s sqlite3

    参考文献:#293

  • unicode修复startswith()/ endswith()

    参考文献:#296

0.2.7 ¶ T0>

发布日期:2006年8月12日
  • quoting facilities set up so that database-specific quoting can be turned on for individual table, schema, and column identifiers when used in all queries/creates/drops. 通过Table或Column中的“quote = True”以及Table中的“quote_schema = True”启用。感谢Aaron Spike的出色努力。

  • assignmapper was setting is_primary=True, causing all sorts of mayhem by not raising an error when redundant mappers were set up, fixed

  • 在映射器中添加了allow_null_pks选项,允许某些主键列为空的行(即映射到外部连接等时)

  • modifcation to unitofwork to not maintain ordering within the “new” list or within the UOWTask “objects” list; instead, new objects are tagged with an ordering identifier as they are registered as new with the session, and the INSERT statements are then sorted within the mapper save_obj. INSERT命令已经基本上一直推到flush周期的末尾。that way the various sorts and organizations occurring within UOWTask (particularly the circular task sort) don’t have to worry about maintaining order (which they weren’t anyway)

  • 固定反射外键,以自动加载引用的表,如果它尚未加载

    • 将URL查询字符串参数传递给connect()函数

    参考文献:#256

    • oracle布尔类型

    参考文献:#257

  • 默认情况下,关系中的自定义主/辅连接条件将传播到backrefs。指定backref()将覆盖此行为。

  • better check for ambiguous join conditions in sql.Join; propagates to a better error message in PropertyLoader (i.e. relation()/backref()) for when the join condition can’t be reasonably determined.

  • sqlite creates ForeignKeyConstraint objects properly upon table reflection.

  • 调整来源于所做的更改。如果连接实际上成功,溢出计数器只应递减。添加一个测试脚本来尝试测试。

    参考文献:#224

  • fixed mysql reflection of default values to be PassiveDefault

  • 添加了“tinyint”,“mediumint”类型到MS-SQL。

    参考文献:#263#264

  • SingletonThreadPool has a size and does a cleanup pass, so that only a given number of thread-local connections stay around (needed for sqlite applications that dispose of threads en masse)

  • 使用懒惰的加载器修复了一些小酱菜bug

    参考文献:#267#265

  • 修正了mysql反射中可能出现的错误,其中某些版本返回一个数组而不是字符串作为SHOW CREATE TABLE调用

  • 在映射到连接时修复延迟加载

    参考文献:#1770

  • all create()/drop() calls have a keyword argument of “connectable”. “引擎”已被弃用。

  • 修正了ms-sql connect()与adodbapi

  • 将“nowait”标志添加到Select()

  • inheritance check uses issubclass() instead of direct __mro__ check to make sure class A inherits from B, allowing mapper inheritance to more flexibly correspond to class inheritance

    参考文献:#271

  • SelectResults will use a subselect, when calling an aggregate (i.e. max, min, etc.) 在具有ORDER BY子句的SelectResults

    参考文献:#252

  • 修正了类型,使数据库特定的类型更容易使用;修复了mysql文本类型以使用该方法

    参考文献:#269

  • 对sqlite日期类型组织的一些修复

  • 将MSTinyInteger添加到MS-SQL

    参考文献:#263

0.2.6 ¶ T0>

发布日期:2006年7月20日
  • big overhaul to schema to allow truly composite primary and foreign key constraints, via new ForeignKeyConstraint and PrimaryKeyConstraint objects. 现有的主键/外键创建方法没有改变,但在幕后使用这些新的对象。表的创建和反射现在更多的是以表格为导向而不是以列为导向的。

    参考文献:#76

  • overhaul to MapperExtension calling scheme, wasn’t working very well previously

  • 调整到ActiveMapper,支持自引用关系

  • 稍微重新安排到objectstore(在activemapper / threadlocal中),这样SessionContext就被'.context'引用,而不是直接被子类化。

  • activemapper will use threadlocal’s objectstore if the mod is activated when activemapper is imported

  • 对URL正则表达式的小修改,允许在其中使用“@”的文件名

  • 修复Session expunge / update / etc ...需要更多的清理

  • select_table mappers still weren’t always compiling

  • 修正了布尔数据类型

  • added count()/count_by() to list of methods proxied by assignmapper; this also adds them to activemapper

  • connection exceptions wrapped in DBAPIError

  • ActiveMapper now supports autoloading column definitions from the database if you supply a __autoload__ = True attribute in your mapping inner-class. 目前这不支持反映任何关系。

  • 在某些情况下,延迟的列加载可能会导致flush()中的连接状态,这是固定的

  • expunge()不能和cascade一起工作,是固定的。

  • 固定级联操作中潜在的无限循环

  • added “synonym()” function, applied to properties to have a propname the same as another, for the purposes of overriding props and allowing the original propname to be accessible in select_by().

  • 修复了在子句构造中的输入,它特别有助于与polymorphic_union类型的问题(CAST / ColumnClause将其类型传播到代理列)

  • mapper compilation work ongoing, someday it’ll work....moved around the initialization of MapperProperty objects to be after all mappers are created to better handle circular compilations. 现在所有的属性都会调用do_init()方法,如果这样的话,它们会更清楚它们的“继承”状态。

  • 显式加载显式禁止自引用关系,或与继承映射器(也是自引用)的关系

  • reduced bind param size in query._get to appease the picky oracle

    参考文献:#244

  • 在table.create()/ table.drop()中添加了“checkfirst”参数,以及table.exists()

    参考文献:#234

  • 继承的一些其他正在进行的修复

    参考文献:#245

  • 属性/ backref / orphan /历史跟踪调整像往常一样...

0.2.5 ¶ T0>

发布日期:2006年7月08日
  • fixed endless loop bug in select_by(), if the traversal hit two mappers that referenced each other

  • 升级了所有的unittests以将'./lib/'插入到sys.path中,解决了新的setuptools PYTHONPATH - 查杀行为

  • 进一步修复属性/依赖关系/ etc ....

  • 改进了DynamicMetaData未连接时的错误处理

  • MS-SQL support largely working (tested with pymssql)

  • 组中的UPDATE和DELETE语句的顺序现在按照主键值的顺序,对于更多的确定性排序

  • after_insert/delete/update mapper extensions now called per object, not per-object-per-table

  • 进一步修复/重构映射器编译

0.2.4 ¶ T0>

发布时间:2006年6月27日
  • try/except when the mapper sets init.__name__ on a mapped class, supports python 2.3

  • fixed bug where threadlocal engine would still autocommit despite a transaction in progress

  • lazy load and deferred load operations require the parent object to be in a Session to do the operation; whereas before the operation would just return a blank list or None, it now raises an exception.

  • Session.update() is slightly more lenient if the session to which the given object was formerly attached to was garbage collected; otherwise still requires you explicitly remove the instance from the previous Session.

  • 修复了映射器编译,检查更多错误条件

  • 小订单,加载订单/限制/偏移

  • utterly remarkable: added a single space between ‘CREATE TABLE’ and ‘(’ since that’s how MySQL indicates a non- reserved word tablename.....

    参考文献:#206

  • 更多修复了继承问题,与多对多关系正确地保存

  • fixed bug when specifying explicit module to mysql dialect

  • when QueuePool times out it raises a TimeoutError instead of erroneously making another connection

  • Queue.Queue usage in pool has been replaced with a locally modified version (works in py2.3/2.4!) 它使用一个线程来处理互斥。这是为了解决报告的情况,在Queue的get()方法中调用了ConnectionFairy的__del __()方法,然后通过put()方法将其连接返回到Queue,导致可重入的挂起,除非使用线程。 ¶ T0>

  • postgres will not place SERIAL keyword on a primary key column if it has a foreign key constraint

  • cursor() method on ConnectionFairy allows db-specific extension arguments to be propagated

    参考文献:#221

  • lazy load params正确传播列类型

    参考文献:#225

  • new MySQL types: MSEnum, MSTinyText, MSMediumText, MSLongText, etc. 更多支持MS特定的长度/精度参数在数字类型补丁提供Mike Bernson

  • 修正连接池invalidate()

    参考文献:#224

0.2.3 ¶ T0>

发行日期:2006年6月17日
  • overhaul to mapper compilation to be deferred. 这允许映射器以任何顺序构造,并且当映射器第一次使用时它们的相互关系被编译。

  • 修复了级联行为的一个非常大的速度瓶颈,特别是当backrefs被使用时

  • 属性检测模块已被完全重写;现在它变得更简单,更清晰,速度更快。属性的“历史”不再是每个更改的微观管理,而是实例首次加载时创建的“CommittedState”对象的一部分。HistoryArraySet消失了,列表属性的行为现在更开放了(即它们不再是集合)。

  • 内部使用的py2.4“set”结构,回退到集合。当“set”不可用时/排序需要时,设置

  • fix to transaction control, so that repeated rollback() calls don’t fail (was failing pretty badly when flush() would raise an exception in a larger try/except transaction block)

  • “foreignkey” argument to relation() can also be a list. 固定的自动外键检测

    参考文献:#151

  • 固定的错误,其中模式名称的表格没有在MetaData对象中正确索引

  • fixed bug where Column with redefined “key” property wasn’t getting type conversion happening in the ResultProxy

    参考文献:#207

  • 固定URL的“port”属性是一个整数(如果存在)

  • fixed old bug where if a many-to-many table mapped as “secondary” had extra columns, delete operations didn’t work

  • 针对UNION查询映射的错误修正

  • 修正不存在DB驱动程序时抛出的不正确的异常类

  • 在反映不存在的表时添加了NonExistentTable异常

    参考文献:#138

  • small fix to ActiveMapper regarding one-to-one backrefs, other refactorings

  • overridden constructor in mapped classes gets __name__ and __doc__ from the original class

  • fixed small bug in selectresult.py regarding mapper extension

    参考文献:#200

  • 对cascade_mappers的小调整,目前不是很强大的支持函数

  • some fixes to between(), column.between() to propagate typing information better

    参考文献:#202

  • 如果一个对象构造失败,不会被添加到会话中

    参考文献:#203

  • CAST function has been made into its own clause object with its own compilation function in ansicompiler; allows MySQL to silently ignore most CAST calls since MySQL seems to only support the standard CAST syntax with Date types. 兼容MySQL的CAST支持字符串,整数等一个TODO

0.2.2 ¶ T0>

发行时间:2006年6月5日
  • 对多态继承行为的重大改进,使其能够与邻接列表表结构一起工作

    参考文献:#190

  • 主要的修复和重构对整体的继承关系,更多的单元测试

  • fixed “echo_pool” flag on create_engine()

  • fix to docs, removed incorrect info that close() is unsafe to use with threadlocal strategy (its totally safe !)

  • create_engine() can take URLs as string or unicode

    参考文献:#188

  • firebird support partially completed; thanks to James Ralston and Brad Clements for their efforts.

  • Oracle url translation was broken, fixed, will feed host/port/sid into cx_oracle makedsn() if ‘database’ field is present, else uses straight TNS name from the ‘host’ field

  • 使用unicode标准修复query.get()/ query.load()

  • count() function on selectables now uses table primary key or first column instead of “1” for criterion, also uses label “rowcount” instead of “count”.

  • 获得了基本的“映射到多个表”功能清理,更正确地记录

  • restored global_connect() function, attaches to a DynamicMetaData instance called “default_metadata”. 将MetaData arg保留为Table out将使用默认的元数据。

  • 修复会话级联行为,entity_name propigation

  • 将单元测试重新组织为子目录

  • 更多修正了threadlocal连接嵌套模式

0.2.1 ¶ T0>

发行时间:2006年5月29日
  • “pool” argument to create_engine() properly propagates

  • 修正了URL,如果没有解析就抛出异常,不会传递空白字段到数据库连接字符串(像user:host @ / db这样的字符串在postgres上)。 T1>

  • 当Mapper插入并尝试获取新的主键值时,对其进行小修改

  • 重写了TLEngine的一半,ComposeSQLEngine与'strategy =“threadlocal”'一起使用。它现在正确地实现了与connection.begin()/ trans.commit()完全嵌套的engine.begin()/ engine.commit()。增加了大约六个单元测试。

  • major “duh” in pool.Pool, forgot to put back the WeakValueDictionary. 本来应该检查这个的unittest也默默地想念它。固定unittest以确保ConnectionFairy正确地超出范围。

  • placeholder dispose() method added to SingletonThreadPool, doesn’t do anything yet

  • 当引发异常时,会自动调用rollback(),但只有在进程中没有事务的情况下才会自动调用(即更类似于autocommit)。

  • 如果没有sqlite模块存在,修正sqlite中的异常

  • 为关联对象doc 添加了额外的示例细节

  • 连接添加了已经关闭的检查

0.2.0 ¶ T0>

发行日期:2006年5月27日
  • overhaul to Engine system so that what was formerly the SQLEngine is now a ComposedSQLEngine which consists of a variety of components, including a Dialect, ConnectionProvider, etc. 这影响了所有的db模块以及Session和Mapper。

  • create_engine now takes only RFC-1738-style strings: driver://user:password@host:port/database

  • total rewrite of connection-scoping methodology, Connection objects can now execute clause elements directly, added explicit “close” as well as support throughout Engine/ORM to handle closing properly, no longer relying upon __del__ internally to return connections to the pool.

    参考文献:#152

  • overhaul to Session interface and scoping. 使用hibernate风格的方法,包括query(class),save(),save_or_update()等。没有threadlocal范围默认安装。为特定的引擎和/或连接提供绑定接口,以便底层Schema对象不需要绑定到引擎。增加了一个基本的SessionTransaction对象,可以简化多个引擎之间的事务处理。

  • overhaul to mapper’s dependency and “cascade” behavior; dependency logic factored out of properties.py into a separate module “dependency.py”. 现在“级联”行为是明确可控的,适当执行“删除”,“删除孤儿”等。依赖系统现在可以在刷新时间确定子对象是否有父对象,以便更好地决定在子对象中如何更新子对象的删除操作。

  • overhaul to Schema to build upon MetaData object instead of an Engine. 整个SQL / Schema系统可以在没有任何引擎的情况下使用,仅由显式连接对象执行。“绑定”方法通过模式对象的BoundMetaData存在。ProxyEngine通常不再需要,被DynamicMetaData取代。

  • 实现了真正的多态行为,修复

    参考文献:#167

  • “oid” system has been totally moved into compile-time behavior; if they are used in an order_by where they are not available, the order_by doesn’t get compiled, fixes

    参考文献:#147

  • overhaul to packaging; “mapping” is now “orm”, “objectstore” is now “session”, the old “objectstore” namespace gets loaded in via the “threadlocal” mod if used

  • mods now called in via “import ”. 扩展模式更喜欢mod,因为mods是全局的,monkeypatching

  • 修复add_property,使其传播属性以继承mappers

    参考文献:#154

  • backrefs create themselves against primary mapper of its originating property, priamry/secondary join arguments can be specified to override. 帮助他们使用多态映射器

  • “表存在”功能已经实现

    参考文献:#31

  • “create_all/drop_all” added to MetaData object

    参考文献:#98

  • 拓扑排序算法的改进和修复,以及更多的单元测试

  • tutorial page added to docs which also can be run with a custom doctest runner to ensure its properly working. docs通常会被大修,以处理新的代码模式

  • 更多的修复,重构。

  • 迁移指南可在维基上的http://www.sqlalchemy.org/trac/wiki/02Migration