sqlalchemy

How do I escape the - character in SQLite FTS3 queries?

I'm using Python and SQLAlchemy to query a SQLite FTS3 (full-text) store and I would like to prevent my users from using the - as an operator. How should I escape the - so users can search for a term containing the - (enabled by changing the default tokenizer) instead of it signifying "does not contain the term following the -"? ...

How to bulk insert data to mysql with python

Currently i'm using Alchemy as a ORM, and I look for a way to speed up my insert operation, I have bundle of XML files to import for name in names: p=Product() p.name="xxx" session.commit() i use above code to insert my data paser from batch xml file to mysql,it's very slow also i tried to for name in names: p=Produc...

use sqlalchemy entity isolately

i just want to use an entity modify it to show something,but don't want to change to the db, but after i use it ,and in some other place do the session.commit() it will add this entity to db,i don't want this happen, any one could help me? ...

SqlAlchemy: get object instance state

This: Intro to object states lists the four permutations of presence-in-DB/presence-in-session: transient, pending, persistent & detached Is there any way of querying a given object to return which of the four states the object is in? I tried rooting around in _sa_instance_state but couldn't find anything relevant. Thanks! ...

Using sqlchemy in Pyqt, is it possible?

Hi i am new to Pyqt and i am wondering if it is possible to have goodness of sqlalchemy e.g. connection pooling and managing, abstracting away all the menial low level details? ...

SqlAlchemy: problem pickling pending instances (association_proxy)

I've successfully pickled persistent instances freshly loaded from the DB, but I can't seem to do the same for an instance that I've just created, and is in session.new. Getting the following error (the python pickle module had the more helpful version of the message): *** PicklingError: Can't pickle <function <lambda> at 0xb08d3ac>: ...

sqlalchemy query refresh issue after use mysql load file

i use a sqlalchemy as my orm,i do a mysqlimport cmd through subprocess,and before & after the execution i query the db records,which i use statistics_db method, but the records count results after import from csv didn't increase,i think this is a sqlalchemy problem,how to slove this?,thanks def statistics_db(f): @wraps(f) def wr...

How do I instruct SQLAlchemy to create SQLite FTS3 tables on create_all()?

I would like SQLAlchemy to create an FTS3 table during .create_all(). What special options do I need to add so it knows to CREATE VIRTUAL TABLE ... USING FTS3(tokenizer=...)? ...

sqlalchemy Move mixin columns to end

I have a sqlalchemy model, where all most all tables/objects have a notes field. So to try follow the DRY principle, I moved the field to a mixin class. class NotesMixin(object): notes = sa.Column(sa.String(4000) , nullable=False, default='') class Service(Base, NotesMixin): __tablename__ = "service" service_id = sa.Colum...

Is it possible to issue a "VACUUM ANALYZE <tablename>" from psycopg2 or sqlalchemy for PostgreSQL?

Well, the question pretty much summarises it. My db activity is very update intensive, and I want to programmatically issue a Vacuum Analyze. However I get an error that says that the query cannot be executed within a transaction. Is there some other way to do it? ...

How to configure sqlalchemy to throw error messages in english ?

Sqlalchemy is throwing me error messages in french On my french-configured linux (ubuntu) lappy. What do I have to do to have those error messages in english ? PS : (my-coriolis)chaouche@jogger:~/$ echo $LANG en_US.utf8 (my-coriolis)chaouche@jogger:~/$ ...

Sharing model between Camelot and non-Camelot apps

I would like to share my data model between different Elixir/SQLAlchemy applications, one of which would be a Camelot UI and the others stuff like web interfaces and so on. They would all connect to the same underlying database. As far as I know, to build a Camelot app my model would do from camelot import blah and that would prevent it...

MySQL server has gone away error with Pylons, SQLAlchemy, Apache

sorry if this is addressed, but i'm running apache2 SQLAlchemy 0.5.8 Pylons 1.0 Python 2.5.2 and on a simple page (just retrieve data from DB), I get: Error - : (OperationalError) (2006, 'MySQL server has gone away') every few other requests, not after a long time as other posts I've searched for. I still added sqlalchemy....

Where is the best place to associate a 'form display text' with SQLAlchemy mapped property?

In django orm I can use the 'verbose_name' kwarg to set a label that will be displayed in model forms. Now I'm dynamically generating WTForms for each model in a SQLAlchemy mapped backend, but I'm not sure where to associate a display text to use in the auto generated fields for each form. For example, in django I could do this: class U...

What are the benefits of using Elixir...

... vs declarative sqlalchemy ? ...

sqlalchemy COUNT and IF

Hi, anyone know how can i do counting if in SQL alchemy like COUN(IF(table_row = 1 AND table_row2 =2),1,0) i make something like this, func.COUNT(func.IF((TransactionMessage.tm_read==0 and TransactionMessage.tm_type==1),1,0)).label('t_message_count'), But sqlalchemy make 2 seperate if with TransactionMesssage.tm_read, and Transa...

dynamic load better choice than joinedload?

Hello, I'd like to know what the best choice is. This is what I do in my system: I'm using grok server and python on the server side; and javascript on the client side. I store all the user data in a session object and this data gets called twice, one to render the HTML on the server side and another to send the data to the client side...

sqlalchemy many-to-many, but inverse?

I'm sorry if inverse is not the preferred nomenclature, which may have hindered my searching. In any case, I'm dealing with two sqlalchemy declarative classes, which is a many-to-many relationship. The first is Account, and the second is Collection. Users "purchase" collections, but I want to show the first 10 collections the user hasn't...

Tables Relationship in Python/Grok (MeGrok)

Hi! How are you doing today? I'm writing because I have a database problem. I am trying to migrate a Grok/Zope application from ZopeDB to MySql, and I don't know exactly how to specify one of the relationships between tables... I am using “megrok.rdb” and “sqlalchemy”. I have four classes involved: A record with some information (l...

Why does this SQLAlchemy example commit changes to the DB?

This example illustrates a mystery I encountered in an application I am building. The application needs to support an option allowing the user to exercise the code without actually committing changes to the DB. However, when I added this option, I discovered that changes were persisted to the DB even when I did not call the commit() meth...