sqlobject

Database change underneath SQLObject

I'm starting a web project that likely should be fine with SQLite. I have SQLObject on top of it, but thinking long term here -- if this project should require a more robust (e.g. able to handle high traffic), I will need to have a transition plan ready. My questions: How easy is it to transition from one DB (SQLite) to another (MySQ...

IronPython db-api 2.0

Does anyone know which if any db-api 2.0 drivers work with IronPython? If so, has anyone tried using it with SQLAlchemy, SQLObject or the Django ORM? ...

Any reasons not to use SQLObject over SQLAlchemy?

I don't expect to need much more than basic CRUD type functionality. I know that SQLAlchemy is more flexible, but the syntax etc of sqlobject just seem to be a bit easier to get up and going with. ...

Executing SQL LIKE in SQLObject

Is there a pretty way to execute an SQL statement with a LIKE clause in SQLObject? This one: fields = Foo.select("field LIKE '%%%s%%'" % bar) works, but it's somewhat ugly. ...

Error while importing SQLObject on Windows

Hi. I am getting following error while importing SQLObject on Window. Does anyone knows what is this error about and how to solve it? ============================== from sqlobject import * File "c:\python26\lib\site-packages\sqlobject-0.10.4-py2.6.egg\sqlobject\__init__.py", line 5, in <module> from main import * File "c:\p...

How to do create_or_update in sqlobject?

I'm using SQLobject and so far was not able to find a elegant solution for "update row in the db or vreate a new one if it doesn't exist. Currently I use following somewhat convoluted code: args = dict(artnr=artnr, name=name, hersteller='?', hersteller_name='?') if cs.datamart.ArtNrNameHersteller.selectBy(artnr=artnr).count(): row ...

Is this a good approach to avoid using SQLAlchemy/SQLObject?

Rather than use an ORM, I am considering the following approach in Python and MySQL with no ORM (SQLObject/SQLAlchemy). I would like to get some feedback on whether this seems likely to have any negative long-term consequences since in the short-term view it seems fine from what I can tell. Rather than translate a row from the database ...

Sorting by a field of another table referenced by a foreign key in SQLObject

Is it possible to sort results returned by SQLObject by a value of another table? I have two tables: class Foo(SQLObject): bar = ForeignKey('Bar') class Bar(SQLObject): name = StringCol() foos = MultipleJoin('Foo') I'd like to get foos sorted by the name of a bar they are related to. Doing: foos...

Using illegal names in MySQL through SQLObject

How to use illegal names for MySQL with SQLObject? In pure SQL it is possible to use backquotes, say: SELECT `select from` FROM table1 WHERE 1; ...can be used to select the field called select from. Is it possible to tell SQLObject to utilize backquotes? ...

SQLObject: How do I prevent a specific class from being cached?

SQLObject caching is very aggressive for me. Can I prevent one specific class from being cached? ...

SQL Server: Can INFORMATION_SCHEMA Tell Me When a SQL Object Was Created?

Given: I added a non-nullable foreign key to a table. I settled on a way to populate the foreign key with default values. I checked in both changes to a re-runnable DB creation script. Other developers ran this script, and now they have the foreign key populated with default values on their developer machines. A few days later howeve...

sqlobject: No connection has been defined for this thread or process

I'm using sqlobject in Python. I connect to the database with conn = connectionForURI(connStr) conn.makeConnection() This succeeds, and I can do queries on the connection: g_conn = conn.getConnection() cur = g_conn.cursor() cur.execute(query) res = cur.fetchall() This works as intended. However, I also defined some classes, e.g: ...

sql select from a large number of IDs

I have a table, Foo. I run a query on Foo to get the ids from a subset of Foo. I then want to run a more complicated set of queries, but only on those IDs. Is there an efficient way to do this? The best I can think of is creating a query such as: SELECT ... --complicated stuff WHERE ... --more stuff AND id IN (1, 2, 3, 9, 413, 4324, ....

SQL get data out of BEGIN; ...; END; block in python

I want to run many select queries at once by putting them between BEGIN; END;. I tried the following: cur = connection.cursor() cur.execute(""" BEGIN; SELECT ...; END;""") res = cur.fetchall() However, I get the error: psycopg2.ProgrammingError: no results to fetch How can I actually get data this way? Likewise, if I just have ma...

create temporary table from cursor

Is there any way, in PostgreSQL accessed from Python using SQLObject, to create a temporary table from the results of a cursor? Previously, I had a query, and I created the temporary table directly from the query. I then had many other queries interacting w/ that temporary table. Now I have much more data, so I want to only process 10...

Python: get escaped SQL string

When I have a cursor, I know I can safely execute a query as follows: cur.execute("SELECT * FROM foo WHERE foo.bar = %s", (important_variable,)) Is there any way to just get the string safely without executing the query? For example, if important_variable is a string, like "foo 'bar' \"baz", I'd want the appropriately escaped one: "S...

Django: Store Hierarchical Data

Hi, I'm trying to store sections of a document in a Django app. The model looks like: class Section(models.Model): project = models.ForeignKey(Project) parent_section = models.ForeignKey('Section', blank=True, null=True, related_name='child_set') predecessor_section = models.ForeignKey('Section', blank=True, null=True, related_na...

How to represent SQL statement in SQLObject.

How do I represent the following SQL statement in SQLObject? The document is not very clear for me. SELECT report_params.* FROM report_params JOIN report_freq_map ON report_id = report_params.id JOIN report_frequency ON freq_id = report_frequency.id WHERE frequency = 'daily' Thanks, -peter ...