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...
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?
...
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.
...
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.
...
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...
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 ...
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 ...
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...
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 caching is very aggressive for me. Can I prevent one specific class from being cached?
...
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...
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:
...
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, ....
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...
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...
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...
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 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
...