.
Marco
On Tuesday, June 14, 2016 at 1:46:19 PM UTC+1, Mike Bayer wrote:
>
> Let's do an MCVE:
>
> from sqlalchemy import *
> from sqlalchemy.orm import *
> from sqlalchemy.ext.declarative import declarative_base
>
> Base = declarative_base()
>
>
> cla
_default=text("NULL"))
but it makes no difference.
Can someone help? Thanks!
Marco
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to sqlalc
easily.
Thanks!
Marco
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to
Hello,
we are moving to python3 and we ran into the error - is there anything we
should do differently?
Thanks
Marco
(alembic==0.8.5)
INFO [alembic.runtime.migration] Context impl MySQLImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
Traceback (most recent call last
to it
- this seems to be due to some module introspection done by the mapper that
appears to be dependent on what modules are imported and in what order.
I'll be happy to learn of better ways to achieve the same end goal.
Cheers
Marco
--
You received this message because you are subscribed
Hi,
straight from the docs:
engine = create_engine('sqlite:///:memory:')
metadata = MetaData()
user = Table('user', metadata,
Column('user_id', Integer, primary_key = True),
Column('user_name', String(16), nullable = False),
Column('email_address', String(60), key='email'),
below.
(Python 2.7.2, Mac OS X)
https://dl.dropboxusercontent.com/u/1980224/alembic_bug.tar.gz
Cheers!
Marco
--
You received this message because you are subscribed to the Google Groups
sqlalchemy-alembic group.
To unsubscribe from this group and stop receiving emails from it, send an email
_ColumnEntity(query, c, namespace=column)
if c is not column:
return
Cheers
Marco
--
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email
SQLA 0.9.3
On Thursday, March 13, 2014 5:09:51 PM UTC-7, Marco wrote:
Hi,
this line (in red) seems mis-indented:
if not isinstance(column, expression.ColumnElement) and \
hasattr(column, '_select_iterable'):
for c in column._select_iterable
Hi
on sqlalchemy 0.7.4
Using ForeignKeyConstraint it happens that join() or outerjoin() does
not find foreign keys
while using ForeignKey on field declaration works (see attachment), is
this a nomal sa behaviour?
Thanks
--
You received this message because you are subscribed to the Google
Hello, everyone. I can't find anythin on the we regarding this
subject, here's a snippet of my code:
friendship = Table(
'friendships', Base.metadata,
Column('friend_a_id', Integer, ForeignKey('users.id'),
primary_key=True),
Column('friend_b_id', Integer, ForeignKey('users.id'),
to write stored procedures for doing
this inline within a query, but each query would trigger a table scan
and perform poorly. I would love to know if I am wrong, as this is an
issue that I will also need to resolve.
Marco
On Apr 24, 5:15 am, Andrew Volozhanin linuxhead...@gmail.com wrote:
Hello
This script lock in the update statement following select for update:
eng=sqlalchemy.create_engine('postgres://x.loc/db')
metadata=sqlalchemy.MetaData()
metadata.bind=eng
tab1 = Table('tab1', metadata, autoload=True)
a_rec =
tab1.select( for_update=True
Sorry. I speak english in rare occasions.
No.
It is not an insert into a join.
The result of a join between tables A and B is the VALUES partial set
for an insert into table C.
sql = A.join(B).select(A.c.id == an_id, fold_equivalents=True,
use_labels=False)
rec = sql.execute().fetchone()
no more correspond to the originals
and then
to the table C columns labels.
I am new to sqlalchemy.
Is there a better solution ?
Can I avoid fold_equivalents in this case?
Thanks!
Marco Vaccari
--
You received this message because you are subscribed to the Google Groups
sqlalchemy group
Opsss!
dict(zip(record.keys(), record.items())
must be
dict(record.items())
On 19 Mar, 16:23, marco vaccari agat...@gmail.com wrote:
Consider 3 tables A,B,C
A JOIN B ON A.id = B.id
produce all the columns required for an insert into C.
I can write:
C.insert().values(dict(zip(record.keys
Michael Bayer ha scritto:
Marco De Felice wrote:
Hi all
This unusual problem appeared today.
I have a mapper extension that gets called twice if I do a query on a
relate_table while updating properties of a mapped object.
I do something like this:
myObj = myMappedObject
session.begin
By the way, I just wanted to let you know that while I don't usually use
this mailing list, we're on the way to have a gui application used on
production that uses sqlalchemy and it all works very well (also
considering the little time I have to study SA, I just use it)
--
You received this
Hi,
I think it would be cool to have an option to obtain the results of a
sqlalchemy query as a numpy's recarray, instead of a list of tuples as
it is now.
Examples:
data = session.query(People.name, People.surname, People.apples,
People.pears).as_recarray()
data['name']
Albert
Mario
Luigi
Hi
I have a huge Agents table with many relations and a Orders table
with agent field related via r_agent to Agents.
When I filter like orders.r_agent.has(Agents.name.ilike(test)) the
query is too slow.
I came up with creating a view Agents_small on the database Agents
table whith only a few
Michael Bayer ha scritto:
Is the solution that you created a new table which is receiving a copy of
some rows (essentially materialized view) ? otherwise I don't see what
is allowing a speed change.
Thanks, that confirms my suspects. There's some problem elsewhere in my
code.
On Tue, May 12, 2009 at 4:54 AM, James rent.lupin.r...@gmail.com wrote:
So:
- what is the recommended database initialisation / cleanup strategy
for unit tests involving SA?
- can anyone suggest how ORM state could be hanging around between
unit tests (I'm using an in-memory DB)?
- is there
Michael Bayer wrote:
the most straightforward way is to have Parent/Child descend from a
common base class and use concrete table inheritance in conjunction
with polymorphic_union, as described in :
given the structure below (pasted from SA 0.5 docs of association object):
left_table = Table('left', metadata,
Column('id', Integer, primary_key=True),
Column('l_data', String(50))
right_table = Table('right', metadata,
Column('id', Integer, primary_key=True),
Column('r_data',
While migrating I came across the following sequence of actions, I had
some old code that called session.close() elsewhere in the application
and also I tend to use sqlalchemy as a temporary object cache knowing
this is somewhat discouraged.
Anyway is it correct that nothing happens when calling
Hi
I'm thinking about a simple client side table audit with SA. Given the
audit log pattern: http://martinfowler.com/ap2/auditLog.html
wouldn't it be simple to adapt it to a mapped class?
I was thinking of a log() function inside the mapped class that if
called saves data into a second table
Stefano Bartaletti wrote:
I need to gather IDs in after_commit because theID is a serial Postgres value
that is available only after flush()
Not really... in postgres, you can ask to consume the next sequence
value with SELECT NEXTVAL('sequence_name') and explicitly set that as
primary
Vladimir Iliev wrote:
hi, is it possible to add a non-caching column_property() to my mapping?
You can use expire() on a single column, so you could proxy that column
with a @property that also expires it.
--
This e-mail (and any attachment(s)) is strictly confidential and for use only
Rick Morrison wrote:
Hi Marco,
[...]
Thank you. Very helpful.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe
I need to evaluate a third-party application, that will be integrated
with others by one of my programs.
My integration app runs on linux with SA 0.4, and I will strive to use
the latest stable release.
I need to write a couple of requirements to choose the third-party
application.
Will I
lur ibargutxi wrote:
'idindicatorgroupcontainer' : relation(IndicatorGroups,
primaryjoin=sql.and_(IndicatorGroups.idindicatorgroup==GroupGroups.idindicatorgroupcontainer)),'idindicatorgroupcontained'
: relation(IndicatorGroups,
lur ibargutxi wrote:
I forgot. Try using tables instead of classes that are not mapped yet..
mappers['groupgroups'] = mapper(GroupGroups, tables['groupgroups'],
properties = {
'idindicatorgroupcontainer' : relation(IndicatorGroups,
Lukasz Szybalski wrote:
dev.cfg has
sqlalchemy.dburi=mysql://user:[EMAIL PROTECTED]:3306/dbname
sqlalchemy.convert_unicode = True
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To post
James Brady ha scritto:
Hi Marco, assign_mapper did help - the relations are now accessible
through my models, and the query syntax is nicer than pure SA as well
in my opinion.
However, I'm using the identity framework (part of TurboGears)
Me too.
which unfortunately doesn't play nicely
James Brady ha scritto:
The problem I'm hitting at the moment is how to properly select simple
objects... There seems to be two main approaches, for example:
session.query(Ownership).select() or
ownership_table.select().execute()
With the first approach, I get
InvalidRequestError: Parent
Lukasz Szybalski ha scritto:
I am trying to insert a record with a compound primary key that consists of
Team_Sid, User_Sid
I can either do
i = users_table.insert()
i.execute(TEAM_SID=343, USER_SID=1,TEAM_NAME='the team')
i.execute(TEAM_SID=343, USER_SID=2,TEAM_NAME='the team')
Travis Kriplean ha scritto:
However, this seems a bit ugly. Is there a way to obtain a non-
transactional connection from an engine in 0.3.10? If not, is it
possible in 0.4?
I use this with SA 0.3.10 and Postgres:
Michael Bayer ha scritto:
its most likely uncompiled mappers. the c attribute on the class
is deprecated; use Table.attribute instead.
...
Thanks, but it seems the Table.c.attribute has a .op() method that I
can't find on Table.attribute
With SA 0.4beta4 if I try to access a mapped object field
(Table.c.fieldname) before any query has been sent to the database the
call fails with a AttributeError(key). Everything works if I do this
after having issued a query.
-- Example: (skip to the __main__ section)
import sqlalchemy as sqa
Lukasz Szybalski ha scritto:
Got another error here. but I guess its fixed in a newer version of
sqlalchemy via ticket 482
Yes. I wasn't aware of 482 because I usually try to avoid table names
that _must_ be escaped (mixed caps, reserved words, etc).
put assign_mapper() in place of
Glauco ha scritto:
Thank you kevin , i've worked a lot over PG and this tecnique is
consolidated in our model.. but here the problem is that the column
is a simplycolumn_name INTEGER NOT NULL references
other_table(id) and i cannot understand why sqlalchemy whant to use it
as a
Lukasz Szybalski ha scritto:
bind_meta_data()
users_table = Table('users', metadata, autoload=True)
class Users(object):
pass
usersmapper=mapper(Users,users_table)
assign_mapper() in place of mapper()
mysession=session.query(Users)
1. What would be the code from now on to
Alexandre CONRAD ha scritto:
Maybe this should need some attention to implement in SA some API to
handle nodes (insert, move, remove) of herachical trees in SA the
Nested Set way.
There are several ways to implement schema and rules (and therefore
APIs) just by looking at Celko's
Michael Bayer ha scritto:
can i have an example
http://trac.turbogears.org/browser/branches/1.0/turbogears/database.py?rev=2320
281 [run_with_transaction.when(_use_sa())]
282 def sa_rwt(func, *args, **kw):
283 log.debug(New SA transaction)
284 transaction =
svilen ha scritto:
Anyway it may depend which audience are u targeting with these names -
those who never seen an API or those for which names are important
only to associate them with a library/version/use-case... both
extremes are equaly uninteresting imo.
I think targeting those
[EMAIL PROTECTED] ha scritto:
here some theory on comparing data trees, in order to produce the
changeset edit scripts.
http://www.pri.univie.ac.at/Publications/2005/Eder_DAWAK2005_A_Tree_Comparison_Approach_to_Detect.pdf
The complete title of the paper is A Tree Comparison Approach To
Anton V. Belyaev ha scritto:
again, im not opposed to this feature and ill patch in an adequate
(and fully unit-tested) implementation. but have you actually ever
*had* this problem? or is it just hypothetical ?
For example, a developer modifies the metadata and checks in. Another
Hi all for my first post
I'm using the new one() method like this:
query(Table).filter_by(and_(Table.c.field1 == val1, Table.c.field2 ==
val2)).one()
filed1 + field2 has a unique constraint in Table, so there won't never
be more than one row returned, but there may be none.
When there's none I
Roger Demetrescu ha scritto:
query.get(dict(columnB='foo', columnA='bar')
Lazy programmers are the best ones... :)
That's the reason lazy programmers share a superclass for all their
domain objects... hint, hint :-)
--~--~-~--~~~---~--~~
You received
svilen ha scritto:
on a side note, here or for the query(), once i add .order_by() and
similar, will be a possibility to remove/cancel them?
e.g. .order_by(None) - similar to .join(None)?
or should i keep a copy at the point before adding .order_by()?
e.g.
i want:
q1 = query.filter(
svilen ha scritto:
because q1 with the order is _the_ query, made at point A somewhen,
and stored there as a construct; much later at some point B i need to
use that query but without the ordering - now i have to keep 2 copies
of the query, w/ and w/out order. And this strip-the-ordering
Sanjay ha scritto:
BTW, the session transaction is stored in
cherrypy.request.sa_transaction.
Yes, but it's been added recently.
Does this help simplify the statements?
Transaction instances have a connection() property.
So, cherrypy.request.sa_transaction.connection should work.
Sanjay ha scritto:
Need help on how to do it. Being a turbogears application where db
entities like metadata and session are imported rather than created by
me, I am confused and could not successfully implement the pattern
provided in the docs.
I'm sure there are cleaner ways, but this
Edin Salkovic ha scritto:
Currently, SQLAlchemy's setup(...) hasn't set this arg, meaning that
setuptools uses its own algorithm to determine if SQLAlchemy can be
installed as a zipped egg.
You can switch off zip for all newly installed eggs, in ~/.pydistutils.cfg
[easy_install]
zip_ok
Michael Bayer wrote:
please file a ticket for this.
done, #535
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To post to this group, send email to [EMAIL PROTECTED]
To unsubscribe from this
I'm not trying the trunk, and it's the first time I use filter_by, but I
guess:
MappedClass.query().filter_by( MappedClass.column_name == 'Foo' )
equates to filter_by(False), because the .c is missing and it's
comparing an UOWProperty to a string, instead of a Column object to a string
I know I can have bound parameters in engine.text():
t = engine.text(select foo from mytable where lala=:hoho)
r = t.execute(hoho=7)
...but I need the same for connection.execute(), since I am using
temporary tables and they are not accessible via engine.text
Should I resort to manual
Andreas Jung wrote:
In a traditional application you can insert a new row and read the row
within the same transaction. What is the typical usage pattern to deal
with this in SA? In our particular setup (Zope) a new session is
created for
each new HTTP request and flushed automatically at
Paul Johnston wrote:
Hi,
Well, more than improving the quality of the article, we need to make
a case for it being notable. The main criteria for this is:
Software is notable if it has been the subject of multiple
non-trivial published works whose source is independent of the
software's
svilen wrote:
how much OO u want?
He's not using a DBMS. He has more OO-ness than SA could give him :-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To post to this group, send email to
I'm working inside TurboGears, autoload everything.
Tested with 0.3.3 and Trunk.
I find this strange behaviour: when I declare a relation between a
Person and a Contract:
assign_mapper(context, Contract, tbl['contracts'], properties = {
'responsible' : relation(Person,
Marco Mariani wrote:
john.contracts_responsible
gives me
AttributeError: 'Person' object has no attribute 'contracts_responsabile'
this is a cut-n-translate-n-paste typo, should read
contracts_responsible of course
--~--~-~--~~~---~--~~
You received
milena wrote:
I have tried
select([func.count(*)], from_obj=[table_name]).execute()
but it didn't work
I suppore you're not using mappers, so this is the fastest method:
number_of_rows = table.count().execute().fetchone()[0]
where table is the table object
Michael Bayer wrote:
to have aliases of properties that are usable with get_by(), use the
synonym function, described in:
http://www.sqlalchemy.org/docs/adv_datamapping.myt#advdatamapping_properties_overriding
Thank you. Altough the docs are very well done, there are many APIs and
that
Hi there
This relates to Turbogears, but is really a SA question.
I've customized TG authentication authorization to use my autloaded
tables in Postgres and SqlAlchemy 0.3.3.
In my schema, I have User.c.uid, the login name of the users, as a
primary key
TG uses a User mapper with two
Lee McFadden wrote:
Going from the line number in your exception that would be because
your columns are of type String. Change the columns to Unicode and it
should solve your problem.
foo_table = Table('foo', metadata,
Column('id', Integer, primary_key=True),
Column('bar',
Does sqlalchemy have some limit in handling composite primary keys with
autoload?
I've tried postgres 8.1 and SA 0.3 or trunk.
I have a 'tree' of four tables, and SA does not create the full join to
follow composite foreign keys.
The schema and test model is in the attachment.
As I've seen,
67 matches
Mail list logo