Query.gino.execution_options
shortcut (#659)@db.declared_attr(with_table=True)
(#659)None
being returned for objects with values of all selected columns are None (#729)gino[pg]
for the old behaviorGINO 1.0 moved the built-in Web framework extensions into separate PyPI packages. If you're using one of them, you should install GINO 1.0 with extras:
Extension Module | Installation in GINO 1.0 |
---|---|
gino.ext.starlette |
pip install gino[starlette] |
gino.ext.aiohttp |
pip install gino[aiohttp] |
gino.ext.sanic |
pip install gino[sanic] |
gino.ext.tornado |
pip install gino[tornado] |
gino.ext.quart |
pip install gino[quart] |
The new extension packages are backward-compatible, so there's no need to
update the import statements. For example, this will still work in GINO 1.0 if
you installed gino[starlette]
:
from gino.ext.starlette import Gino
GINO 1.0 switched to Poetry for package and dependency management and started to use the src layout. This shouldn't cause any problem using GINO as a dependency, but it does introduce some changes to the GINO development process:
src
directory.none_as_none()
is now always enabled.set_bind()
from manipulation.assert
with AssertionError
(#258 #655)This is also version 1.0 release candidate.
We introduced aiocontextvars 0.2.0 which is revamped to be compatible with
PEP-567 without manual interference by a few simple implicit patches. To
upgrade to GINO 0.8, please remove the enable_inherit()
or
disable_inherit()
calls, because they are the default behavior now thus
no longer exist. However, you'll need to confirm that the event loop in use is
always created after importing gino
or aiocontextvars
, or the patch
won't work correctly.
There is nothing to worry about in Python 3.7.
When GINO tries to load a row with all NULL
values into an instance, it
will now by default return None
instead of an instance with all None
attributes. To recover the default behavior of 0.7, please specify
none_as_none(False)
in affected model loader.
This is especially applicable to relationship sub-loaders - if the sub-loader
found it all NULL
, no instance will be set to parent instance. For
example:
child = await Child.load(parent=Parent).query.gino.first()
If child.parent_id
is NULL
in database, then the child
instance
won't be called with any setattr(child, 'parent', ...)
at all. (If you need
child.parent == None
in this case, consider setting default value
parent = None
in child model.)
Please note, it is deprecated to disable none_as_none
, and disabling will
be removed in GINO 1.0.
with_bind
usability in aiohttp extension (#518)JSONPathType
bind processor for asyncpg (#609)distinct()
to Alias
(#628)__tablename__
in declared_attr
(Contributed by Roald Storm in #592)__tablename__
to be a declared_attr
(#579 #582)Label
(#365)>=1.2
(#378 #382)(Most fixes done by Tony Wang)
model.load()
(Contributed by Jekel in #323)none_as_none()
the default behavior (#351)This is also version 1.0 beta 3.
none_as_none()
(#281 #282)ARRAY
alias in asyncpg dialect module (Contributed by Mykyta Holubakha in #289)Model.lookup()
to prevent updating whole table without primary key (#287 #288)DB_ECHO
in extension options (Contributed by Mykyta Holubakha in #298)UninitializedError
if bind is None
(Contributed by Tony Wang in #307 #310)declared_attr
(#204)ModelLoader
passively load partial model (#216)dict
as ident for Model.get
(#192)This is also version 1.0 beta 2.
We created a new Python package aiocontextvars from previous local.py
. If
you made use of the task local features, you should install this package.
Previous gino.enable_task_local()
and gino.disable_task_local()
are
replaced by aiocontextvars.enable_inherit()
and
aiocontextvars.disable_inherit()
. However in GINO 0.5 they controls the
whole task local feature switch, while aiocontextvars by default offers task
local even without enable_inherit()
, which controls whether the local
storage should be passed between chained tasks. When enabled, it behaves the
same as enabled in 0.5, but you cannot completely turn off the task local
feature while aiocontextvars is installed.
There is no gino.get_local()
and gino.reset_local()
relevant in
aiocontextvars. The similar thing is aiocontextvars.ContextVar
instance
through its get()
, set()
and delete()
methods.
Previous gino.is_local_root()
is now
not aiocontextvars.Context.current().inherited
.
GINO 0.6 hides asyncpg.Pool
behind the new SQLAlchemy-alike
gino.GinoEngine
. Instead of doing this in 0.5:
async with db.create_pool('postgresql://...') as pool: # your code here
You should change it to this in 0.6:
async with db.with_bind('postgresql://...') as engine: # your code here
This equals to:
engine = await gino.create_engine('postgresql://...') db.bind = engine try: # your code here finally: db.bind = None await engine.close()
Or:
engine = await db.set_bind('postgresql://...') try: # your code here finally: await db.pop_bind().close()
Or even this:
db = await gino.Gino('postgresql://...') try: # your code here finally: await db.pop_bind().close()
Choose whichever suits you the best.
Obviously GinoEngine
doesn't provide asyncpg.Pool
methods directly any
longer, but you can get the underlying asyncpg.Pool
object through
engine.raw_pool
property.
GinoPool.get_current_connection()
is now changed to current_connection
property on GinoEngine
instances to support multiple engines.
GinoPool.execution_option
is gone, instead update_execution_options()
on GinoEngine
instance is available.
GinoPool().metadata
is gone, dialect
is still available.
GinoPool.release()
is removed in GinoEngine
and Gino
, the
release()
method on GinoConnection
object should be used instead.
These methods exist both in 0.5 GinoPool
and 0.6 GinoEngine
:
close()
, acquire()
, all()
, first()
, scalar()
, status()
.
Similarly, GinoConnection
in 0.6 is no longer a subclass of
asyncpg.Connection
, instead it has a asyncpg.Connection
instance,
accessable through GinoConnection.raw_connection
property.
GinoConnection.metadata
is deleted in 0.6, while dialect
remained.
GinoConnection.execution_options()
is changed from a mutable dict in 0.5 to
a method returning a copy of current connection with the new options, the same
as SQLAlchemy behavior.
GinoConnection.release()
is still present, but its default behavior has
been changed to permanently release this connection. You should add argument
permanent=False
to remain its previous behavior.
And all()
, first()
, scalar()
, status()
, iterate()
,
transaction()
remained in 0.6.
All five query APIs all()
, first()
, scalar()
, status()
,
iterate()
now accept the same parameters as SQLAlchemy execute()
,
meaning they accept raw SQL text, or multiple sets of parameters for
"executemany". Please note, if the parameters are recognized as "executemany",
none of the methods will return anything. Meanwhile, they no longer accept the
parameter bind
if they did. Just use the API on the GinoEngine
or
GinoConnection
object instead.
Transaction interface is rewritten. Now in 0.6, a GinoTransaction
object is
provided consistently from all 3 methods:
async with db.transaction() as tx: # within transaction async with engine.transaction() as tx: # within transaction async with engine.acquire() as conn: async with conn.transaction() as tx: # within transaction
And different usage with await
:
tx = await db.transaction() try: # within transaction await tx.commit() except: await tx.rollback() raise
The GinoConnection
object is available at tx.connection
, while
underlying transaction object from database driver is available at
tx.transaction
- for asyncpg it is an asyncpg.transaction.Transaction
object.
Abandoned version, please use 0.7.0 instead.
create()
on model instances (Contributed by Kinware in #178 #180)get()
by string, and misc environment issues (Contributed by Tony Wang in #191 193 #183 #184)create
and drop
for Enum
type (#160)Pool
replaced with Engine
Engine
replaced asyncpg Pool
(#59)multiparams
(executemany) to return correctly (#20)bind
Gino
no longer exposes postgresql
typesecho
on engine (#142)gino
extension on SchemaItem
for create_all
and so on (#76 #106)gino
extension on model classes for create()
or drop()
_update_request_cls
on CRUDModel
(#147)This is also version 1.0 beta 1.
Enum
in creation (Contributed by Sergey Kovalev in #126)This is an emergency fix for 0.5.6.
Model.outerjoin
Model.join
and made Model
selectable (Contributed by Ádám Barancsuk in #112 #113)Model.insert
(Contributed by Neal Wang in #63)no module named cutils
error (Contributed by Vladimir Goncharov in #73)This is an emergency fix for 0.5.0.
RowProxy
first_or_404
GinoPool
cannot be inheriteddialect
and execution contextguess_model
, switched to explicit execution optionstimeout
parameter to an execution optionpool
, connection
and api
from asyncpg_delegate
Considered as alpha releases.
select
on model instanceget_or_404
more friendly when Sanic is missing (Contributed by Neal Wang in #23 #31)sqlalchemy.__all__
(Contributed by Neal Wang in #10 #33)lazy
parameter on db.acquire
(Contributed by Binghan Li in #32)iterate
API to be compatible with asyncpg (#32)update
API (#29)__table_args__
(#12)query.gino
extension for in-place executionweakref
on __model__
of table and query (Contributed by Tony Wang)timeout
parameter (Contributed by Neal Wang in #16 #22)update
and delete
APIdb.bind
conn
renamed to optional bind
db.create_pool
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。