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

SQLAlchemy 1.1文档

0.2 Changelog

0.2.8 ¶ T0>

发布日期:2006年9月5日
  • 清理连接方法+文档。在查询字符串中指定的自定义DBAPI参数,'create_engine'的'connect_args'参数或通过'creator'函数创建自定义创建函数到'create_engine'。

  • 在池中添加了“recycle”参数,在create_engine上是“pool_recycle”,默认为3600秒;在这个年龄段之后的连接将被关闭并替换为新的,以处理自动关闭陈旧连接的db

    参考文献:#274

  • 用连接池改变了“无效”语义;将指示底层连接记录在下次调用时重新连接。如果在对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

  • 工作单元可更好地检查属于“删除孤儿”级联的“孤儿”对象,对于父级不可级联的某些情况,¶ T1>

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

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

  • 当工作单元试图将它们作为关系的一部分flush()时,改进了对作为会话一部分的对象的检查。

  • 语句执行支持在表达式中多次使用相同的BindParam对象;简化位置参数的处理。Bill Noon很好地理解了基本思想。

    参考文献:#280

  • 使用pg_schema表移动postgres反射,可以用use_information_schema = create_engine的真实参数覆盖。

    References: #60, #71

  • 添加了MetaData,Table,Column的case_sensitive参数,根据父模式项是否具有标志的非None设置自动确定自身,如果不是,则标识符名称是全部小写还是不。当设置为True时,引用应用于具有混合或大写标识符的标识符。引用也会在所有情况下自动应用于已知为保留字或包含其他非标准字符的标识符。各种数据库方言可以覆盖所有这些行为,但是目前他们都使用默认行为。用postgres,mysql,sqlite,oracle进行测试。需要使用firebird,ms-sql进行更多测试。正在进行的工作的一部分

    参考文献:#155

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

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

    参考文献:#281

  • 在UNION查询中添加了限制/偏移量(尽管尚未在oracle中)

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

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

    参考文献:#287

  • 自动加载失败时,从元数据中取消注册Table;

    参考文献:#289

  • 导入py2.5s sqlite3

    参考文献:#293

  • unicode修复startswith()/ endswith()

    参考文献:#296

0.2.7 ¶ T0>

发布日期:2006年8月12日星期六
  • 设置的引用工具,以便在所有查询/创建/删除中使用针对单个表,模式和列标识符的特定于数据库的引用。通过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周期的末尾。这样,在UOWTask中发生的各种排序和组织(特别是循环任务排序)不必担心维护顺序(它们不是无论如何)

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

    • 将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在表反射时正确创建ForeignKeyConstraint对象。

  • 由于所做的更改而导致的池调整。溢出计数器只应在连接实际成功时递减。添加了一个测试脚本来尝试测试。

    参考文献:#224

  • 固定mysql的默认值反射为PassiveDefault

  • 在MS-SQL中添加了'tinyint','mediumint'类型。

    参考文献:#263#264

  • SingletonThreadPool有一个大小并执行一个清理过程,因此只有给定数量的线程本地连接保留(对于集体处理线程的sqlite应用程序是必需的)

  • 使用懒惰加载程序修复小泡菜bug

    参考文献:#267#265

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

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

    参考文献:#1770

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

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

  • 在Select()中添加了“nowait”标志

  • 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

  • 在调用聚合时(即max,min等),SelectResults将使用子选择符。在具有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

  • 对MapperExtension调用方案进行了大修,之前的工作并不完善

  • 调整为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映射器静态并不总是编译

  • 修正了布尔数据类型

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

  • 封装在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,fixed。

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

  • 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()方法,如果这样的话,它们更能意识到它们的“继承”状态。

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

  • 在query._get中减少绑定参数的大小以安抚挑剔的oracle

    参考文献:#244

  • 在table.create()/ table.drop()以及table.exists()方法中添加了'checkfirst'参数

    参考文献:#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(用pymssql测试)

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

  • after_insert / delete / update现在称为每个对象的映射器扩展,而不是每个对象每个表

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

0.2.4 ¶ T0>

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

  • 固定的错误,其中threadlocal引擎仍会自动提交,尽管事务正在进行中

  • 延迟加载和延迟加载操作要求父对象在Session中进行操作;而在操作刚刚返回一个空白列表或None之前,它现在会引发一个异常。

  • 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!) 它使用一个线程.Lock来进行互斥。这是为了解决在Queue的get()方法中调用ConnectionFairy的__del __()方法,然后通过put()方法将其连接返回到Queue的报告情况,导致可重入的挂起,除非使用线程.lock。 ¶ 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

  • 延迟加载绑定参数正确地传播列类型

    参考文献:#225

  • 新的MySQL类型:MSEnum,MSTinyText,MSMediumText,MSLongText等更多支持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”结构,回退到sets.Set何时“set”不可用/需要排序

  • 修复事务控制,以便重复的rollback()调用不会失败(当flush()会在更大的try / except事务块中引发异常时,会非常糟糕)¶< / T1>

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

    参考文献:#151

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

  • 固定错误,其中带有重定义的“key”属性的Column没有在ResultProxy 中发生类型转换¶

    参考文献:#207

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

  • 修复了旧bug,如果多对多映射为“次要”的表有额外的列,删除操作无效

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

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

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

    参考文献:#138

  • 针对ActiveMapper的一对一后向引用,其他重构的小修复

  • 映​​射类中的重载构造函数从原始类获取__name__和__doc__

  • 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函数已经在ansicompiler中用自己的编译函数编写成自己的子句对象;允许MySQL默默地忽略大多数CAST调用,因为MySQL似乎只支持带Date类型的标准CAST语法。与MySQL兼容的CAST支持字符串,整数等一个TODO

0.2.2 ¶ T0>

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

    参考文献:#190

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

  • 在create_engine()上固定了“echo_pool”标志

  • 修复文档,删除了不正确的信息,close()与threadlocal策略一起使用是不安全的(它完全安全!)

  • create_engine()可以将URL作为字符串或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”.

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

  • 恢复了global_connect()函数,并附加到名为“default_metadata”的DynamicMetaData实例。将MetaData arg保留为Table out将使用默认元数据。

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

  • 将unittests重新组织为子目录

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

0.2.1 ¶ T0>

发布日期:2006年5月29日
  • “pool” argument to create_engine() properly propagates

  • 修复了URL,如果不解析,会引发异常,不会传递空白字段到数据库连接字符串(一个字符串,如user:host @ / db在postgres上破解) T1>

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

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

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

  • 添加到SingletonThreadPool的占位符dispose()方法,不会执行任何操作

  • 当引发异常时,会自动调用rollback(),但只有在进程中没有事务时才会自动调用(即,更像自动提交)。

  • 如果没有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作用域。为特定的引擎和/或连接提供绑定接口,以便底层架构对象不需要绑定到引擎。增加了一个基本的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

  • 现在通过“import ”调用mods。 T1>扩展模式在mods中的优势在于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”添加到MetaData对象

    参考文献:#98

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

  • 教程页面添加到文档中,也可以使用自定义doctest运行器来运行以确保其正常工作。docs通常会被彻底检查以处理新的代码模式

  • 更多的修复,重构。

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