Application consists of:
main process (python+sqlalchemy) that
periodically check db (sleeps most
of the time)
child processes that write to db
web app that write to db
Problem is that the main process session doesn't seem to register changes in the db done outside that session. How do ensure it does? (as of now I am closing and...
All,
Update: based on google result and answer, I added more hints, still not finished.
In using sqlite3 and during study of sqlalchemy, I found it is necessary to write below code for those housekeeping purpose for managing data, however, it may be a hard part for me to doing that in sqlalchemy then I turning back to sqlite3 module.
...
How can I call stored procedures of sql server with sqlAlchemy?
...
is it possible to override the default type.DateTime behaviour when using sqlalchemy with raw sql expressions?
for example when using
myconnection.execute(text("select * from mytable where mydate > :mydate), {'mydate': mypythondatetimeobject)}
, i would like to have type.DateTime to automatically strip the TimeZone from the DateTime ...
Hello,
I have a complex database where user object is related almost to every table in some way. In a previous post, I asked how to get read-only objects. I found out I could use the option "joinedload" when I query database. It's working fine, but I have another problem.
These are my tables:
class User(rdb.Model):
"""Set up user...
I've got a query that returns a fair number of rows, and have found that
We wind up throwing away most of the associated ORM instances; and
building up those soon-to-be-thrown-away instances is pretty slow.
So I'd like to build only the instances that I need!
Unfortunately, I can't do this by simply restricting the query; I need to...
I'm using Django to nicely display stats etc from an Oracle database that I only have/want read access to. Because the database has composite primary keys I'm not using Django's ORM layer and I'm using SQLAlchemy instead. The only installed apps I have are my own, and of the MIDDLEWARE_CLASSES I'm only using CommonMiddleware.
Based on t...
I want to do something like this:
select username, userid, 'user' as new_column from users_table.
The columns of the table can be selected using sqlalchemy as follows:
query = select([users_table.c.username, users_table.c.userid])
How do I do the select x as col_x to the query in sqlalchemy?
...
I am defining a SQLAlchemy model like this:
class SubProject(Base):
active = Column(Boolean)
class Project(Base):
active = Column(Boolean)
subprojects = relationship(SubProject, backref=backref('project'))
class Customer(Base):
active = Column(Boolean)
projects = relationship(Project, backref=backref('customer'))
I need to...
Dear All,
After I read SQLAlchemy's FAQ I think below code may works,
import sqlalchemy.pool as pool
import sqlite3 as sqlite3
conn_proxy = pool.manage(sqlite3)
# then connect normally
connection = conn_proxy.connect(...)
however I also get below snippets:
engine = create_engine(...)
conn = engine.connect()
conn.co...
I have an sqlite db that has some crazy ascii characters in it and I would like to remove them, but I have no idea how to go about doing it. I googled some stuff and found some people saying to use REGEXP with mysql, but that threw an error saying REGEXP wasn't recognized.
Here is the error I get:
sqlalchemy.exc.OperationalError: (Ope...
EDITED QUESTION
I'm trying to create a class factory that can generate enumeration-like classes with the following properties:
Class is initialized from the list
of allowed values (i.e., it's
automatically generated!).
Class creates one instance of itself
for each of the allowed value.
Class does not allow the creation of
any addition...
I am seeking for a library of predefined models for SQLAlchemy.
I think of something like you have in LDAP where you can just use an existing schema like inetOrgPerson, ipHost, ... and don't have to bother creating the structure.
...
I am trying to select all the records from a sqlite db I have with sqlalchemy, loop over each one and do an update on it. I am doing this because I need to reformat ever record in my name column.
Here is the code I am using to do a simple test:
def loadDb(name):
sqlite3.connect(name)
engine = create_engi...
I'm use sqlalchemy 0.6.4.
I have 2 classes: Question and Tag, they are many-to-many.
class Question(Base):
__tablename__ = "questions"
id = Column(Integer, primary_key=True)
deleted = Column(Boolean)
...
tags = relationship('Tag', secondary=r_questions_tags)
class Tag(Base):
__tablename__ = "tags"
id = Co...
I've two classes: Question and Answer. A question may have 0 or many answers.
class Question(Base):
__tablename__ = "questions"
answers = relationship('Answer', backref='question',
primaryjoin="Question.id==Answer.question_id")
class Answer(Base):
__tablename__ = "answers"
Now I want to find al...
I am trying to use sqlalchemy to connect with mysql database. I have set up charset=utf-8$use_unicode=0. This worked with almost all databases, but not with a particular one. I believe it is because it has 'init-connect' variable set to 'SET NAMES latin2;' I have no privileges to change that.
It works for me if I send explicit query SET...
hi,
I'm new to sqlalchemy and could use some help.
I'm trying to write a small application for which i have to dynamically change a select-statement. So I do s = select([files]), and then i add filters by s = s.where(files.c.createtime.between(val1, val2)).
This works great, but only with an AND-conjunction.
So, when I want to have all ...
I know how to query on a model now. Suppose there is a Question model:
class Question(Base):
__tablename__ = "questions"
id=Column(...)
user_id=Column(...)
...
Now, I can do:
question = Session.query(Question).filter_by(user_id=123).one()
But, now, I have a table (not a model) questions:
questions = Table('question...
I have a class X which derives from a class with its own metaclass Meta. I want to also derive X from the declarative base in SQL Alchemy. But I can't do the simple
def class MyBase(metaclass = Meta):
#...
def class X(declarative_base(), MyBase):
#...
since I would get metaclass conflict error: 'the metaclass of a derived cl...