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?
http://docs.sqlalchemy.org/en/rel_1_1/core/functions.html

Are there any related functions for which a better description is also
in a waiting queue?

Regards,
Markus

-- 
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 sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


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 try
something out like the following on a string field.

…
  for length, \
  incidence in session.query(func.len(position.label),
 func.count(position.label)
).group_by(func.len(position.label)) \
 .order_by(func.len(position.label)):
…


Is it interesting that the following approach seems to work instead?

…
  for length, \
  incidence in session.query(func.length(position.label),
 func.count(position.label)
).group_by(func.length(position.label)) \
 .order_by(func.length(position.label)):
…


How is the function "length" mapped to the SQL function "LEN"?

Regards,
Markus

-- 
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 sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


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 functions?

Regards,
Markus

-- 
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 sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[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 identifiers will be appropriate for the involved fields?
http://docs.sqlalchemy.org/en/rel_1_0/core/sqlelement.html#sqlalchemy.sql.expression.label

Regards,
Markus

-- 
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 sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[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 = dbSession.query(
>model.Foo.a,
>sqlalchemy.func.count(Model.Foo.b).label('count_b')
>  )
>  inner_query = inner_query.subquery('query_foo')
>  results = 
> dbSession.query(inner_query.c.count_b.label('count_results')).all()

Another part of the desired data analysis is working here now.

Will it become easier to recognise the relevant relationships
from the corresponding programming interface documentation?

Regards,
Markus

-- 
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 sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[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 support for it is still evolving in database implementations
and corresponding software libraries.

Now I am looking for a solution around a similar use case.
How should anything be added (or appended) to the value of a column in a query
as a single action?

Regards,
Markus

-- 
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 sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[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 query method "order_by"?
http://docs.sqlalchemy.org/en/rel_1_0/orm/query.html#sqlalchemy.orm.query.Query.order_by


> session.query(model.Foo).order_by(model.Foo.id.desc(). 
> model.Foo.id_b.asc())

Is the specification "desc()." really appropriate in this parameter list 
example?


> There's also some sql expression in another package...
> http://docs.sqlalchemy.org/en/latest/core/sqlelement.html#sqlalchemy.sql.expression.desc

Thanks for your links.


> If you have a column the standard way is to just do `column.asc()`

I find the detail interesting that the sort direction needs to be written
as a method call instead of passing a corresponding parameter value.


> Using the `desc(column)` syntax is really only necessary when using literal 
> sql
> or very complex queries.

I imagine that I will need this variant for my use case of sorting
computed query fields, won't I?

Regards,
Markus

-- 
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 sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[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 sort criterion.
How should a "ascending" or "descending" direction be expressed as a parameter
for the query method "order_by"?

Regards,
Markus

-- 
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 sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[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

-- 
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 sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


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 single place?

Regards,
Markus

-- 
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 sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


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 configured as a data source
  for the other database so that you would only
  need to deal with a single connection for
  the desired query?

Regards,
Markus

-- 
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 sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


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 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 sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


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
 associated to the engine.

How often do you need to fill these data structures in
a concurrent way?

Does parallel table creation become more interesting then?

Regards,
Markus

-- 
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 sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


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 EXISTS to Python
classes in the meantime eventually?

Regards,
Markus

-- 
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 sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[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 mapped Python classes?

Regards,
Markus

-- 
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 sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


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.


 What if the table definitions are different?

I am going to pass the same settings for the application I am developing
at the moment.


 One of the instructions would *have* to fail.

Not in every case.

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?

* Does it really work in the current praxis?

Regards,
Markus

-- 
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 sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


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 EXISTS will work in a high-concurrency context?

Yes.

How many database implementations support the simultaneous table creation
according to the rules from transaction management?

Regards,
Markus

-- 
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 sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


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 discussed race condition?


 Have you tried using savepoints?

I am going to use a serial database preparation step
instead for my application so that the corresponding
tables will be explicitly deleted and created by
a small SQL script.

Regards,
Markus

-- 
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 sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[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 pg_type_typname_nsp_index
DETAIL:  Key (typname, typnamespace)=(positions_parallel1_line_seq, 2200) 
already exists.
 '\nCREATE TABLE positions_parallel1 (\n\tfunction […], pattern)\n)\n\n' {}
…


The following software components were involved for this
application test on my openSUSE Tumbleweed system.

1. SQLAlchemy 0.9.8-78.1
2. Psycopg 2.5.2-3.1
3. PostgreSQL 9.3.5-3.1
4. Python 2.7.9-2.1
5. Coccinelle spatch 1.0.0-rc23
6. make 4.1-2.2


I have searched a bit on the internet. Are there any further
software development challenges to consider for the parallel
creation of database tables with the object-relational interface?

Regards,
Markus

-- 
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 sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


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 appreciate if I can fill these data structures in parallel
without a serial database preparation step (table creation with
repeated meta-data specification).

Regards,
Markus

-- 
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 sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


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
for parallel updates including concurrent creation of each table.


 A create table would need to be preceded by a check to see that it exists,
 for example, and that would likely need to be mutexed on that name so that
 no race condition occurs in between the time that the name is checked
 vs. the create table is emitted.

I am curious to clarify more software development challenges.
How many open issues are already known around such implementation details?

Regards,
Markus

-- 
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 sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


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 application programming interfaces into
the shape that will provide you with enough error information
so that you can make the corresponding exception handling really
safe, consistent and efficient?


 But if there's even 1 row that violates unique constraint
 none of the hundreds of non-duplicated rows will get updated either.

How much do you need such core database functionality from
transaction management?

Does each record belong to a change which affects the consistency/integrity
for your data structures?

Can data updates be really reordered for failure handling?

Regards,
Markus

-- 
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 sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[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 can omit
a few statements (like Base.metadata.create_all(engine))
there if I want to concentrate on a specific data selection.

How many meta-data will I need to add to the corresponding
class so that the declarative mapping will work for an
existing database table?
Will table properties be automatically mapped into the
provided Python class (without explicit specifications)?

Regards,
Markus

-- 
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 sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


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 error.

Thanks for your explanation.

Do I need to consider any more fine-tuning for my database session?


 The mechanism of a UNIQUE constraint is that this is a database-level
 construct, so the backend database is tasked with checking this
 this condition and reporting on it at statement execution time.

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?

Regards,
Markus

-- 
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 sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


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 executemany(),

Yes. - It seems that this method was used in my use case.


 which receives the full set of records in one batch before any
 communication with the database is established.

Can it happen then that an error will be reported for a single SQL statement
which was submitted within an unit of more database commands?


 SQLAlchemy doesn’t have access to at what point each individual series
 of parameters are invoked as the interface is too coarse-grained.

Do you know any attempts to make the affected error reporting more precise?

Regards,
Markus

-- 
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 sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


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 parameter sets
 at maximum speed.

Thanks for your helpful advice.

Regards,
Markus

-- 
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 sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[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):
   __tablename__ = positions
   function = Column(String, primary_key = True)
   source_file = Column(String, primary_key = True)
   line = Column(Integer, primary_key = True)
   column = Column(Integer, primary_key = True)
   void = Column(Integer, default = 0)
   static = Column(Integer, default = 0)
   data_type = Column(String)
   parameter = Column(String)
...
def store_positions(fun, type, point, places):
Add source code positions to an internal table.
...



Now I stumble on an error message like the following.
...
cursor.executemany(statement, parameters)
sqlalchemy.exc.IntegrityError: (IntegrityError) UNIQUE constraint failed: 
positions.function, 
...


The message might be appropriate in principle for my concrete use case.
But I observe that the constraint violation is reported a bit
too late because I got the impression from corresponding debug
output that three rows were added to the shown table here
with unique attributes.

I would appreciate your explanations and further advices.

Regards,
Markus

-- 
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 sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[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 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 sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


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
https://lkml.org/lkml/2014/12/16/395
https://systeme.lip6.fr/pipermail/cocci/2014-December/001557.html

Are there still further improvement possibilities?

Regards,
Markus

-- 
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 sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.