Re: [sqlalchemy] Determination of string lengths

2015-12-10 Thread SF Markus Elfring
Thanks for the link to information I was looking for: http://stackoverflow.com/questions/15743121/how-to-filter-in-sqlalchemy-by-string-length#answer-15743220 Why is the method "length" not mentioned in the documentation chapter "SQL and Generic Functions" so far?

Re: [sqlalchemy] Determination of string lengths

2015-12-10 Thread SF Markus Elfring
> As stated in the docs: > "Note that any name not known to func generates the function name as is > - there is no restriction on what SQL functions can be called, > known or unknown to SQLAlchemy, built-in or user defined." I get an error message like "Function len(text) does not exist." if I

Re: [sqlalchemy] Determination of string lengths

2015-12-10 Thread SF Markus Elfring
> I don't know which database you are using, > but in postgresql there certainly is a function called "length" How do you think about to avoid the direct reuse of functions which are specific for a few database software implementations? Is there any more portability possible around string

[sqlalchemy] How to refer to fields in nested queries?

2015-12-08 Thread SF Markus Elfring
Hello, I would like to compute a few fields in a query and then apply aggregate functions on corresponding results. I imagine that I would need a subquery (or a specific view) for this use case. How should such a query structure be expressed by interfaces of the software "SQLAlchemy"? Which

[sqlalchemy] Re: How to refer to fields in nested queries?

2015-12-08 Thread SF Markus Elfring
> If you are using a subquery for additional processing or joins, > you can use `label()` to specify the name for the computed column, > then access that column as an attribute on the `.c` columns attribute of the > subquery object. Thanks for your information. > inner_query =

[sqlalchemy] Support for SQL Merge (or Upsert?)

2015-12-08 Thread SF Markus Elfring
Hello, I would like to perform a specific data management task which will affect a combination of checks for the operations "INSERT" and "UPDATE". Such a functionality became part of the SQL standard as the operation "MERGE". https://en.wikipedia.org/wiki/Merge_%28SQL%29 It seems that the

[sqlalchemy] Re: Selection of sort directions

2015-12-06 Thread SF Markus Elfring
> Odd- this isn't the narrative docs Thanks for your clarification. > You can use column attributes... > (http://docs.sqlalchemy.org/en/latest/core/sqlelement.html#sqlalchemy.sql.expression.ColumnElement.desc) Would it help to add a few more descriptions (and links) to the section for the

[sqlalchemy] Selection of sort directions

2015-12-05 Thread SF Markus Elfring
Hello, The software "SQLAlchemy" supports also the handling of the SQL clause "ORDER BY" to some degree. http://docs.sqlalchemy.org/en/rel_1_0/orm/query.html#sqlalchemy.orm.query.Query.order_by Now I am looking for the corresponding description of details for the specification of the desired

[sqlalchemy] Determination of string lengths

2015-12-05 Thread SF Markus Elfring
Hello, I would like to reuse the standard function "len" for the determination of string lengths from specific database fields in a query. http://www.dailyfreecode.com/code/len-function-296.aspx Which interface does provide this functionality for the software "SQLAlchemy"? Regards, Markus --

Re: [sqlalchemy] Difficulties with parallel data insertion into the same table

2015-01-23 Thread SF Markus Elfring
If the table structure/name is known and expected to be used -- there's not really a good reason to defer creating it . Is the reason good enough to avoid the repeated specification of corresponding meta-data? Is it safer to maintain and manage column attributes for some tables only at a

Re: [sqlalchemy] SQL join between two tables from two databases

2015-01-23 Thread SF Markus Elfring
I am trying to do a join between two tables, each residing on a separate databases. Would you like to consider another software design option? * Do you know if any special connectors or data source adaptors are available for your database software implementations? * Can one of them be

Re: [sqlalchemy] Difficulties with parallel data insertion into the same table

2015-01-23 Thread SF Markus Elfring
How are you currently specifying the meta-data? Should the Python class be sufficient for the definition of a table structure? Will the mapping interface work also without tables that were created by other SQL scripts before? Regards, Markus -- You received this message because you are

Re: [sqlalchemy] Difficulties with parallel data insertion into the same table

2015-01-23 Thread SF Markus Elfring
Should the Python class be sufficient for the definition of a table structure? If you're using the declarative syntax, yes. Thanks for your acknowledgement. It's common to have a `models.py` file that simply defines the classes in one place; then that is imported and metadata

Re: [sqlalchemy] Difficulties with parallel data insertion into the same table

2015-01-23 Thread SF Markus Elfring
I wonder why you’re asking of the SQLAlchemy list about a specific developmental goal of the Postgresql project? I hoped that some more corresponding experiences could already be shared here. Wouldn’t you ask them about this? That might follow ... How should I add the parameter IF NOT

[sqlalchemy] Handling of differences between a table and its mapped class

2015-01-23 Thread SF Markus Elfring
Hello, What will (or should) happen if the column attributes which are specified by a class that is derived from declarative_base() differ (e. g. an other default value) from the settings of an existing database table? Is it occasionally appropriate to use different column properties by the

Re: [sqlalchemy] Difficulties with parallel data insertion into the same table

2015-01-23 Thread SF Markus Elfring
I would expect that database implementations will provide functionality for parallel updates including concurrent creation of each table. What would you expect a database to do if it receives 2 CREATE TABLE my_table(...) instructions simultaneously? This depends on the passed parameters.

Re: [sqlalchemy] Difficulties with parallel data insertion into the same table

2015-01-23 Thread SF Markus Elfring
The parameter IF NOT EXISTS could be passed to the SQL statement CREATE TABLE. * Is this setting already used by the class library SQLAlchemy 0.9.8-78.1? From a quick scan of the docs it appears not. How can parameter additions be achieved for this software? Are you asking if IF NOT

Re: [sqlalchemy] Difficulties with parallel data insertion into the same table

2015-01-23 Thread SF Markus Elfring
Using IF NOT EXISTS would not solve this problem in a high concurrency scenario. Thanks for your feedback. There would still be a race condition within the Postgres internal functions. Are there any chances that this database software implementation will become robust and safe against the

[sqlalchemy] Difficulties with parallel data insertion into the same table

2015-01-22 Thread SF Markus Elfring
Hello, I try to write some data from a source code analysis which is performed by a few processor cores simultaneously into a single table. Now I stumble on a message like the following again. … sqlalchemy.exc.IntegrityError: (IntegrityError) duplicate key value violates unique constraint

Re: [sqlalchemy] Difficulties with parallel data insertion into the same table

2015-01-22 Thread SF Markus Elfring
So there is no valid use case for parallel generation of tables except in particular kinds of multi-tenancy situations. I find my use case simple enough (and therefore very valid). I am going to manage two database tables by corresponding Python classes with SQLAlchemy services. I would

Re: [sqlalchemy] Difficulties with parallel data insertion into the same table

2015-01-22 Thread SF Markus Elfring
I would appreciate if I can fill these data structures in parallel without a serial database preparation step (table creation with repeated meta-data specification). You’d need to implement checks for this concurrency. I would expect that database implementations will provide functionality

Re: [sqlalchemy] Handling unique key violations with bulk inserts of large number of rows

2015-01-22 Thread SF Markus Elfring
If I'm doing a bulk insert of a very large number of rows is it possible to add only the ones that don't violate unique constraints and log the rest? Yes. - But such functionality depends on some design details. Would you like to invest any software development efforts to get the involved

[sqlalchemy] ORM code example for a query of a single table

2015-01-15 Thread SF Markus Elfring
Hello, I would like to query a single table by the ORM interface for an export of the stored data into an other file format. The description of the query API refers also to the object relational tutorial. This tutorial explains also functionality which deals with table creation. I imagine that I

Re: [sqlalchemy] Checking the handling of unique keys/indexes

2014-12-21 Thread SF Markus Elfring
SQLAlchemy sends to the log the statement and parameters it is to send to the DBAPI cursor.execute() method, *before* it actually does so. This so that if the DBAPI throws an exception, as is the case here, one can see what instructions were sent to it which were the immediate cause of this

Re: [sqlalchemy] Checking the handling of unique keys/indexes

2014-12-21 Thread SF Markus Elfring
Should I get the exception sqlalchemy.exc.IntegrityError directly after I attempted to insert a second record set with unique attributes into a SQLite table? I don’t have a stack trace here to see what the nature of the issue is but it is likely that the INSERT is proceeding using DBAPI

Re: [sqlalchemy] Checking the handling of unique keys/indexes

2014-12-21 Thread SF Markus Elfring
There is no way to use the second form while being able to record the moment each parameter set is used, unless the DBAPI itself provides additional hooks for logging at this level. However, this logging would defeat some of the purpose of executemany(), which is that of processing many

[sqlalchemy] Checking the handling of unique keys/indexes

2014-12-20 Thread SF Markus Elfring
Hello, I am using source code like the following in one of my scripts where I am trying the software packages SQLAlchemy 0.9.7-77.1 and SQLite 3.8.7.2-1.1 out on my openSUSE system. ... engine = create_engine(sqlite:///:memory:, echo = False) base = declarative_base() class position(base):

[sqlalchemy] Setting column properties

2014-12-19 Thread SF Markus Elfring
Hello, I created another class after reading the object relational tutorial. Now I would like to apply more fine-tuning for corresponding attributes. How can I specify a default value for a column there? Is more documentation available for the class Column? Regards, Markus -- You received

Re: [sqlalchemy] Re: SQLAlchemy: Table creation before data insertion?

2014-12-16 Thread SF Markus Elfring
take your Base object and Base.metadata.create_all(engine) Thanks for your helpful advice. I have integrated it into a small script which I published a moment ago together with a result from static source code analysis. http://article.gmane.org/gmane.linux.kernel/1852033