Questions on sqlalchemy

0 like 0 dislike
43 views
1. Can I use sqlalchemy to retrieve the column names of the DB and somehow dynamically to operate them (without asking them directly in class, which will mapitse)

2. How, in fact, create/delete/edit columns

3. I have records and tags with many-to-many relationship through a third table, e.g. like here. How to write a class for the table of relationships given the fact that there is no primary key?
by | 43 views

4 Answers

0 like 0 dislike
The needs of people are growing, people are tired of statics and dynamics I want more.
Unfortunately, SQL-based DBMS are not designed for dynamic circuits. If you change the scheme, it will lose in performance, very much to lose. And that's despite the fact that SQL(and especially using SA) not so fast.
\r
I advise you to pay attention to more modern solution is a document-oriented database. More precisely MongoDB and MongoKit as a tool for creating and manipulating schemas.
The fact that the document-oriented DBMS created for dynamic data, where the schema may change often. A document in this DB, the same as the entry(row, row) in SQL-based, relational database.
Document is a JSON data structure, where all you can change, add, delete.
The document has no "scheme". Ie wanted to make the document post of the user, and do:
db.posts.save({id:1, author:"James", text:"Howdy!"})
However, schemes are needed, so they make policy decisions like MongoKit.
For example, you can use MongoKit following scheme:
{
name:unicode
data:{unicode:unicode}
}
That will allow you to operate with the dictionary data as you want.
Scheme for a post, for example:
{
id:int,
author:unicode,
text:unicode
}
\r
In General, I advise you to read:
\rwww.mongodb.org/
\rnamlook.github.com/mongokit/
by
0 like 0 dislike
thanks, will look this way, but still I would like to hear at least about the 3rd question
because if you write
\rclass tagged(Base):
__tablename__ = 'tagged'
\r
elem = Column(Integer, key='elem')
tag = Column(Integer, key='tag')
\r
def __init__(self, elem, tag):
self.elem = elem
self.tag = tag
\r

you get the answer sqlalchemy.exc.ArgumentError: Mapper Mapper|tagged|tagged could not assemble any primary key columns for mapped table 'tagged'
and make an extra field in the table would not
by
0 like 0 dislike
Revive a corpse. :-)
SQLAlchemy requires a mandatory(!) presence in the primary key table.
by
0 like 0 dislike
As said REDkiy, just enter:

``
id = db.Column(db.Integer, primary_key=True)
``
by

Related questions

0 like 0 dislike
1 answer
asked Aug 2, 2019 by RaymanPy
0 like 0 dislike
3 answers
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
28,757 users