catches I have to do
to write to other DB's, I can maybe just write raw SQL through sql alchemy
or worst case through pyodbc to deal with collecting the records.
Thank you for the help.
Ken
On Wednesday, November 28, 2018 at 6:12:41 PM UTC-5, Mike Bayer wrote:
>
> Hi there -
>
> U
ads to that.
If I take that statement as is and paste into dbeaver (replacing the \n
with an actual carriage return) everything works.
This fails on both linux (using FreeTDS version set to 5) and windows
(using the dsn name for the actual ASE driver setup in my odbc)
I am confused what is g
very good! It's fine. thank you, Mike Bayer !
On Wednesday, December 20, 2017 at 10:08:49 PM UTC+8, Mike Bayer wrote:
>
> On Wed, Dec 20, 2017 at 4:36 AM, Ken Liu <liuji...@gmail.com >
> wrote:
> > I want to convert query.order_by(cast(Channel.cname, String) to
>
I want to convert query.order_by(cast(Channel.cname, String) to cast(cname AS
CHAR CHARACTER SET gbk),how do I do that? please help me.
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide an MCVE: Minimal,
for this process as
what we are dealing with is a data replication service pulling from a u2
data store to sql server. The delete is part of batch cleanup testing.
On Thursday, August 31, 2017 at 5:13:58 PM UTC-4, Ken MacKenzie wrote:
>
> Tried doing various conversions on the pk values as they
that this can be an issue with pyodbc and that there are engine
settings related to it. Also perhaps I should try using the pymssql driver
to see if that changes anything.
On Thursday, August 31, 2017 at 5:00:47 PM UTC-4, Ken MacKenzie wrote:
>
> So inspecting the elements of the tuple, they are bo
So inspecting the elements of the tuple, they are both str, so hence
unicode.
Are you saying that if I convert those values to bytes it could improve
performance?
> I'd not bother with the literal_binds and just use a literal value:
>
> pkf = [(col == literal_column("'%s'" % v)) for (col,
So here is my solution as of now. As far as I can tell hits the marks of:
1. DB Neutral
2. Performance (9k records deleted in 5 seconds)
3. Generic
(excuse the print statements still there for testing)
Would welcome comments on this proposed solution. I have learned a lot
from the advice in
params.
So I know this is not recommended but to retain DB neutrality can I use the
output from query.statement.compile(dialect=s.bind.dialect,
compile_kwargs={"literal_binds": True}) and feed that output back in direct
to execute?
On Thursday, August 31, 2017 at 6:41:17 AM UTC-4, K
in your original version meant 2000 bind
> parameters.
>
> Try with a batch sizes of 10, 50 and 100. You'll run more queries but
> I suspect each query will perform better.
>
> Simon
>
>> On Wed, Aug 30, 2017 at 10:02 PM, Ken MacKenzie <deviloc...@gmail.com> w
s?
>
> If none of those are issues for you, the textual version is probably
> pretty safe.
>
> Simon
>
>> On Wed, Aug 30, 2017 at 5:30 PM, Ken MacKenzie <deviloc...@gmail.com> wrote:
>> Not sure how I would iterate through a non predetermined number of primary
&
When I get in tomorrow I will take a look at some of these options. I also
intend to spin up a quick MySQL or postgresql db to test if my textual solution
can work against an alternate target.
Sent from my iPad
> On Aug 30, 2017, at 6:20 PM, Jonathan Vanasco wrote:
>
>
different.
On Wednesday, August 30, 2017 at 4:41:38 PM UTC-4, Ken MacKenzie wrote:
>
> I am noticing the 16 execute calls. There should only be 10 with a batch
> size of 1000 and a record size of 9,000 and some change.
>
> Are you just wanting to see the sql via a print(q)?
&
With a batch size of 1 based on the original selection, no improvement.
I am going to see what sql this is creating.
2328928 function calls (2085124 primitive calls) in 1084.925
seconds
Ordered by: internal time
ncalls tottime percall cumtime percall
16 SQL statements that take a very different
> amount of time depending on format. Can you please paste the output
> with echo=True on create_engine() so that the difference in SQL
> statements can be seen?
>
> On Wed, Aug 30, 2017 at 12:30 PM, Ken MacKenzie <devil...@gmail.com
> &
I tried an alternate version:
@classmethod
def dict_delete2(cls, dict_in):
"""
Delete records from the database
based on a dictionary keyed by
PK tuple
"""
s = dbc.get_session()
keys_in = ["-".join(k) for k in dict_in.keys()]
table.c.pk1 == sa.bindparam('pk1'),
> table.c.pk2 == sa.bindparam('pk2'),
> )
> statement = sa.delete(table, whereclause=condition)
> batchparams = [{'pk1': v[0], 'pk2': v[1]} for v in id_batch]
> session.execute(statement, batchparams)
>
> Simon
>
> On
Sorted Textual SQL profile
ncalls tottime percall cumtime percall filename:lineno(function)
161.8400.1151.8400.115 {method 'execute' of
'pyodbc.Cursor' objects}
95720.1960.0000.7880.000 elements.py:1860(_construct)
577000.1890.000
Sorted:
ncalls tottime percall cumtime percall filename:lineno(function)
16 1053.794 65.862 1053.794 65.862 {method 'execute' of
'pyodbc.Cursor' objects}
348916/3483110.5390.0000.5560.000 {built-in method
isinstance}
160920/1609180.3130.0000.313
After the current sorted profile finishes I will revert to the textual
version and run a profile on that. I expect another 10-15 minutes for this
to finish right now.
At present the batch size is set to 1000, total record count is just over
9000 in these tests.
The reason for 1000 was at
t; You could try playing with your batch sizes to see what sort of effect
> that has.
>
> Simon
>
> On Wed, Aug 30, 2017 at 4:01 PM, Ken MacKenzie <devil...@gmail.com
> > wrote:
> > So I implemented this version with one change. I moved this line:
> >
, August 30, 2017 at 4:43:01 AM UTC-4, Simon King wrote:
>
> On Tue, Aug 29, 2017 at 9:49 PM, Ken MacKenzie <devil...@gmail.com
> > wrote:
> > I have a query I have constructed and I had to deal with a composite
> primary
> > key to select items;
> &
eading me to believe that SQL Server (or at least
the version we are using) does not support tuples.
Ken
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable
Thank you everyone for the responses.
I think it is not as big a deal as I might have been expecting,. The
purist in me does not like redefining object. But from an api perspective
there is not cleaner and purpose built name for the field in question.
Ken
--
SQLAlchemy -
The Python SQL
yeah but I have it in the model as
class gltable(Base):
...
object = column(string(6))
On Wed, Aug 9, 2017 at 6:33 PM, Mike Bayer <mike...@zzzcomputing.com> wrote:
> On Wed, Aug 9, 2017 at 2:12 PM, Ken MacKenzie <deviloc...@gmail.com>
> wrote:
> > So I have been usin
into an in use prototype (ain't that always the way).
I just wanted to get some more experienced feedback in case any of the data
consumers start asking why I am wanting to change something that works to
rename this field.
Ken
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http
be greatly appreciated. Sorry if I'm missing something
that is already clearly stated in the documentation.
Best,
Ken
--
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, sen
On Thu, Nov 5, 2015 at 7:34 AM, Mike Bayer <mike...@zzzcomputing.com> wrote:
>
>
> On 11/03/2015 06:55 PM, Ken Lareau wrote:
>
>> I came across this during a search, and in the four different sites
>> I've checked, I've seen four different release dates varying fro
hoping I might be able
to find out more here. :)
--
Ken Lareau
--
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.co
Dave,
Thanks for the response. Unfortunately the switch to PostgreSQL, while not
a long ways away, probably will not occur until at least the beginning of
next year and this rewrite is needed now. If there are no other options
available then I'll just need to brute force it. :)
- Ken
On Wed
rs on
the DB side, but I'm unsure if that's a valid possibility here?
Hopefully this made sense, but if any clarification is needed, please let
me know.
--
Ken Lareau
klar...@ifwe.co
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To u
once, but each relationship in project is triggering its own
delete which is bad.
So... help? Am I missing something simple here, or is my model not good
enough to do the right thing?
--
- Ken Lareau
--
You received this message because you are subscribed to the Google Groups
sqlalchemy group
On Thu, Sep 4, 2014 at 3:30 PM, Michael Bayer mike...@zzzcomputing.com
wrote:
On Sep 4, 2014, at 5:37 PM, Ken Lareau klar...@tagged.com wrote:
So I have a few tables as follows (abbreviated for unnecessary columns):
class Project(Base):
__tablename__ = 'projects'
id = Column
On Thu, Sep 4, 2014 at 4:35 PM, Michael Bayer mike...@zzzcomputing.com
wrote:
On Sep 4, 2014, at 6:58 PM, Ken Lareau klar...@tagged.com wrote:
On Thu, Sep 4, 2014 at 3:30 PM, Michael Bayer mike...@zzzcomputing.com
wrote:
On Sep 4, 2014, at 5:37 PM, Ken Lareau klar...@tagged.com wrote
On Thu, Sep 4, 2014 at 4:54 PM, Michael Bayer mike...@zzzcomputing.com
wrote:
On Sep 4, 2014, at 7:50 PM, Ken Lareau klar...@tagged.com wrote:
Is there a way to essentially allow something like 'for app in
project.applications:' without having
to make an explicit query to the DB first
This is probably violating some normal form, but after playing with it
(Thanks Michael and Jonathan), this seems to work for what I'm using.
Suggestions welcome on improving it.
#!/usr/bin/env python
from sqlalchemy import Column, ForeignKey, Integer, MetaData, Sequence,
String, \
Thanks for the help Jonathan and Michael.
The below seems to work for what I'm doing. Let me know what normal forms
I'm violating with it :)
from sqlalchemy import Column, ForeignKey, Integer, MetaData, Sequence,
String, \
create_engine
from sqlalchemy.orm import backref,
If I'm understanding correctly, something like the following:
# Keep track of manufacturer names
manufacturers_table = Table(u'manufacturer', metadata,
Column(u'id', Integer, primary_key=True,
Column(u'name', String(20))
)
# Keep track of model names
models_table = Table(u'model',
On Monday, July 21, 2014 8:38:54 AM UTC-7, Jonathan Vanasco wrote:
I agree with what Mike said, but I would just suggest renaming
projector_table to something like purchased_table or inventory_table.
Everything in models is a different model of a projector, so the table
names are a bit
Forgot to mention that during typical operation, the only time the database
will be accessed would be during down time (add/delete) or program startup
(retrieve list of projectors to control) - not during a presentation.
--
You received this message because you are subscribed to the Google
and
determine each by hand, but I was wondering if there was a less manual
(and error-prone) way to approach this, possibly via the autogeneration
feature? In case it matters, the database server is MySQL.
--
- Ken Lareau
--
You received this message because you are subscribed to the Google
'PRIMARY' for the name of the constraint
and I'm not even sure that's changeable (been putting together a test data-
base to try it out on)). But I'll see what I can hack together. :)
- Ken
On 7/2/14, 6:08 PM, Ken Lareau wrote:
So, in my ongoing quest to make my team's operations
reciprocal relationships is okay, and are
there certain things that should be done to mitigate potential issues that
can be caused by doing so, or are there better ways to accomplish the
same thing?
--
- Ken Lareau
--
You received this message because you are subscribed to the Google Groups
On Tue, Jul 1, 2014 at 2:17 PM, Mike Bayer mike...@zzzcomputing.com wrote:
On 7/1/14, 4:54 PM, Ken Lareau wrote:
Related to one of my recent posted threads here, I'm recalling a certain
conversation at PyCon where I was mentioning how a friend would define
a many-to-many relationship
On Thu, Jun 26, 2014 at 7:47 PM, Ken Lareau klar...@tagged.com wrote:
On Jun 26, 2014 7:40 PM, Mike Bayer mike...@zzzcomputing.com wrote:
right, so a few emails ago I said:
you need to put .label('environment') on that column before it finds
its way into subq. I dont have
**SIGH** Please ignore last message... I had forgotten to actually
update the database schema itself. :( Pardon me while I go shoot
myself...
- Ken
On Tue, Jul 1, 2014 at 4:19 PM, Ken Lareau klar...@tagged.com wrote:
On Thu, Jun 26, 2014 at 7:47 PM, Ken Lareau klar...@tagged.com wrote
On Thu, Jun 26, 2014 at 5:57 AM, Mike Bayer mike...@zzzcomputing.com
wrote:
On 6/25/14, 8:06 PM, Ken Lareau wrote:
On Wed, Jun 25, 2014 at 6:28 AM, Mike Bayer mike...@zzzcomputing.com
wrote:
On 6/25/14, 2:26 AM, Ken Lareau wrote:
On Tue, Jun 24, 2014 at 3:35 PM, Mike Bayer mike
that might come from the code itself; hopefully I didn't miss any, but
if there's still confusion, let me know.
- Ken
On 6/26/14, 4:11 PM, Ken Lareau wrote:
On Thu, Jun 26, 2014 at 5:57 AM, Mike Bayer mike...@zzzcomputing.com
wrote:
On 6/25/14, 8:06 PM, Ken Lareau wrote:
On Wed, Jun 25
Done, new file attached (this gives the same error message as the one I
showed initially, at least on my system).
- Ken
--
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
, considered it insane. :)
- Ken
On 6/26/14, 9:50 PM, Ken Lareau wrote:
Done, new file attached (this gives the same error message as the one I
showed initially, at least on my system).
- Ken
--
You received this message because you are subscribed to the Google
Groups sqlalchemy group
On Tue, Jun 24, 2014 at 3:35 PM, Mike Bayer mike...@zzzcomputing.com
wrote:
On 6/23/14, 8:09 PM, Ken Lareau wrote:
if apptier:
subq = (
Session.query(
Package.pkg_name,
Package.version,
Package.revision
Anyone? This has me dead in the water and nothing in the documentation
has been helping.
- Ken
On Mon, Jun 23, 2014 at 5:09 PM, Ken Lareau klar...@tagged.com wrote:
On Fri, Jun 20, 2014 at 3:46 PM, Ken Lareau klar...@tagged.com wrote:
On Fri, Jun 20, 2014 at 1:23 PM, Mike Bayer mike
On Fri, Jun 20, 2014 at 3:46 PM, Ken Lareau klar...@tagged.com wrote:
On Fri, Jun 20, 2014 at 1:23 PM, Mike Bayer mike...@zzzcomputing.com
wrote:
On 6/20/14, 3:38 PM, Ken Lareau wrote:
So in the ongoing improvement of one of our internal databases, we
created
a new table named
occur, so
I turn to those with more expertise to find out if there is a way to
accomplish
what I desire, or if there's really no hope. :) Any insight would be
greatly
appreciated.
--
- Ken Lareau
--
You received this message because you are subscribed to the Google Groups
sqlalchemy group
On Fri, Jun 20, 2014 at 1:23 PM, Mike Bayer mike...@zzzcomputing.com
wrote:
On 6/20/14, 3:38 PM, Ken Lareau wrote:
So in the ongoing improvement of one of our internal databases, we
created
a new table named 'environments' whose SQLA code looks something like
this:
class Environment
enough to always understand why my
current code works (and I have a full application using this without issue
at the moment).
So I guess the question is: am I missing something really obvious here,
or will I need to rethink how I deal with sessions in my library code?
Thanks in advance.
--
- Ken
On Fri, Oct 11, 2013 at 5:53 PM, Michael Bayer mike...@zzzcomputing.comwrote:
On Oct 11, 2013, at 7:14 PM, Ken Lareau klar...@tagged.com wrote:
In the process of trying to find an efficient way to manage a test database
for a large set of tests for a database library I'm writing that uses
this time, there will be future
column renames that are far more insidious and may require it, so I would
also like to know if the above will work as well. :)
--
- Ken Lareau
--
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To unsubscribe from
On Tue, Sep 24, 2013 at 7:25 AM, Michael Bayer mike...@zzzcomputing.comwrote:
On Sep 23, 2013, at 10:04 PM, Ken Lareau klar...@tagged.com wrote:
Hopefully this will make sense...
I have a database which is in need of some normalization of the column
naming in various tables
On Tue, Sep 24, 2013 at 10:32 AM, Michael Bayer mike...@zzzcomputing.comwrote:
On Sep 24, 2013, at 12:00 PM, Ken Lareau klar...@tagged.com wrote:
Of course, this leads back to the original question... how exactly
does one accomplish this? :) Hopefully the clarification above helps
On Tue, Sep 24, 2013 at 11:10 AM, Ken Lareau klar...@tagged.com wrote:
On Tue, Sep 24, 2013 at 10:32 AM, Michael Bayer
mike...@zzzcomputing.comwrote:
On Sep 24, 2013, at 12:00 PM, Ken Lareau klar...@tagged.com wrote:
Of course, this leads back to the original question... how
On Tue, Sep 24, 2013 at 2:53 PM, Michael Bayer mike...@zzzcomputing.comwrote:
On Sep 24, 2013, at 5:42 PM, Ken Lareau klar...@tagged.com wrote:
On Tue, Sep 24, 2013 at 11:10 AM, Ken Lareau klar...@tagged.com wrote:
On Tue, Sep 24, 2013 at 10:32 AM, Michael Bayer mike...@zzzcomputing.com
the docs so far hasn't turned up anything useful,
I'm afraid...
Thanks in advance.
--
- Ken Lareau
--
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
This has also been posted here:
http://stackoverflow.com/questions/15950375/sqlalchemy-introspection-of-relationships,
shoulda asked here first.
I have a use case for modelling data in a SQL schema rather than through
defining SQLAlchemy objects. However, i require a way to construct the
and
sqlalchemy.exc.InvalidRequestError: Object 'HostDeployments at 0x21cd050'
is already attached to session '1' (this is '3')
Sadly it's not immediately obvious as to what's going on... not even
certain how
to start debugging this problem.
- Ken
On Tue, Jan 8, 2013 at 2:59 PM, Ken Lareau klar...@tagged.com wrote:
On Tue
On Thu, Jan 17, 2013 at 4:13 PM, Michael Bayer mike...@zzzcomputing.comwrote:
On Jan 17, 2013, at 7:01 PM, Ken Lareau wrote:
On Thu, Jan 17, 2013 at 3:54 PM, Michael Bayer
mike...@zzzcomputing.comwrote:
On Jan 17, 2013, at 6:45 PM, Ken Lareau wrote:
Sadly, it looks like when I try
On Thu, Jan 17, 2013 at 4:26 PM, Michael Bayer mike...@zzzcomputing.comwrote:
On Jan 17, 2013, at 7:24 PM, Ken Lareau wrote:
On Thu, Jan 17, 2013 at 4:13 PM, Michael Bayer
mike...@zzzcomputing.comwrote:
On Jan 17, 2013, at 7:01 PM, Ken Lareau wrote:
On Thu, Jan 17, 2013 at 3:54 PM
On Tue, Jan 8, 2013 at 2:16 PM, Michael Bayer mike...@zzzcomputing.comwrote:
On Jan 8, 2013, at 4:00 PM, Ken Lareau wrote:
Given this and your previous comments, and after some conversations with
a coworker, I decided to expose the 'engine' variable from the database
library and create
Michael,
Thanks for the response, see further questions/issues below...
On Fri, Jan 4, 2013 at 8:41 AM, Michael Bayer mike...@zzzcomputing.comwrote:
On Jan 3, 2013, at 10:18 PM, Ken Lareau wrote:
I recently (today) ran into an issue that has me perplexed as to how to
resolve it,
so I'm
give.
--
- Ken Lareau
--
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 from this group, send email to
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit
am I missing?
Thanks ahead of time.
-Ken
--~--~-~--~~~---~--~~
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 from this group, send email
On Feb 17, 3:13 pm, Michael Trier mtr...@gmail.com wrote:
backref supports the same arguments as relation(), which include an order_by
argument.
http://www.sqlalchemy.org/docs/05/reference/orm/mapping.html?highligh...
Michael, I'm using the order_by argument. The problem is that it's
sorting
On Feb 17, 3:29 pm, Michael Trier mtr...@gmail.com wrote:
Sorry, I misunderstood. You should be able to do a order_by=field.desc().
Ah, that answers my question. Thanks!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
On Feb 4, 6:53 am, Michael Bayer mike...@zzzcomputing.com wrote:
its not really a bug. use real column objects for your order by
expression, i.e.:
order_by=_username,
Oh, that makes sense. Thanks for the explanation.
-Ken
--~--~-~--~~~---~--~~
You
Oh, sorry, forgot to mention:
Python 2.5.2
SQLAlchemy 0.5.2
--~--~-~--~~~---~--~~
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 from
I've created a full test case that should reproduce the error for you.
You'll need to create a database called 'test' on your local machine.
I think I've isolated the problem to the use of the creator keyword
argument, which I use in my application for various reasons.
Oh, I see. I was unaware that lambda evaluated the result only once,
not each use. Thanks so much for your help.
On Dec 19, 4:36 pm, Michael Bayer mike...@zzzcomputing.com wrote:
def setup(**kwargs):
connection = MySQLdb.connections.Connection(**kwargs)
engine =
On Dec 17, 9:24 am, Michael Bayer mike...@zzzcomputing.com wrote:
yes but pool_recycle is documented as a number of seconds, and a
typical value is 3600 for one hour. setting it to True means it will
recycle the connection every second. Technically, that shouldn't
cause any broken
16, 2008, at 1:09 PM, Ken wrote:
I'm using CherryPy with SQLAlchemy. I've tried this with both
SQLAlchemy's scoped_session thread-local sessions, as well as (also
local-to-thread) sessions I create in my web code manually.
2008-12-16 11:51:14,524 DEBUG cherrypy.error.140068141119376
I'm using CherryPy with SQLAlchemy. I've tried this with both
SQLAlchemy's scoped_session thread-local sessions, as well as (also
local-to-thread) sessions I create in my web code manually.
2008-12-16 11:51:14,524 DEBUG cherrypy.error.140068141119376: [16/Dec/
2008:11:51:14] HTTP Traceback (most
partitioning data with members. Once the
alias is created, it can be treated like any other table.
-ken
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To post to this group, send email to sqlalchemy
the list and
return the object -- in which case, would the changes be reflected in
the session / database?
Thanks in advance,
Most impressed so far,
Ken Pierce.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
sqlalchemy
. Was the original goal of the branch [1] too aggressive?
Thanks in advance.
-Ken
[1] Integrating Django and SQLAlchemy, Aug 29, 2006:
http://groups.google.com/group/django-developers/browse_thread/thread/5149e1c60dc65bff
--~--~-~--~~~---~--~~
You received this message because you
Perhaps he's looking for an upsert function? That's sometimes handy, and to
be truly useful would have to be able to use any given key on the table.
I hacked up an upsert for SQLObject once, but it was so ugly I never
contributed it. It did make the poor man's replication system that I was
sqlite. If it's true, then sqlite fails on
the assertion that the manager employee id's be different, and
postgres throws an exception that 'managers_person_id_seq does not
exist'
Thanks in advance for any help, and thanks for an otherwise awesome
product!
-Ken
#!/usr/bin/env python
85 matches
Mail list logo