How to build a flask application around an already existing database?

I already have an existing Database that has a lot of tables and a lot of data in MySQL. I intend to create a Flask app and use sqlalchemy along with it. Now I asked out on irc and looked around...

How to run sqlacodegen?

I'm not understanding why I can't run sqlacodegen. I'm looking to use it for create a SQLAlchemy model from my existing PostgreSQL database. It won't run. When I type sqlacodegen --help for help...

How to reverse engineer data models from an existing database in Python and SQL-Alchemy

I understand that there is a db migration process to create databases/tables using SQL-Alchemy. But I am looking for the reverse. DBAs will create and manage Data definitions and they don't want...

sqlacodegen - can't connect to database

I am trying to use sqlacodegen on my database. sqlacodegen mysql://root:[email protected]/database_name However, I keep receiving this error: sqlalchemy.exc.OperationalError:...

symfony2 or doctrine are removing username field from my entities -- why?

Update: It's not just username that's this affects. I even tried renaming the column to foo in my schema, and still it always returns null for that column! My database is in MySQL (InnoDB). I have...

sqlacodegen issue with geometry type

i'm using sqlacodegen in order to automatically generate model code for SQLAlchemy. My problem is that I have some columns of type geometry and as far as I know, according to the link bellow,...

Sqlacodegen generates mixed models and tables

Executing this command: sqlacodegen <connection-url> --outfile db.py The db.py contains generated tables: t_table1 = Table(...) and classes too: Table2(Base): __tablename__ =...

BIT 0 represented as '\x00'

In a database table I have a column defined as: Using this query: query = text( "SELECT * FROM %s WHERE " % "aTable" "%s=%s AND " % ("done", 0) ) ...

How to use the same field as foreign key for different tables?

I have a number of tables that will work as source data, one per scientific area (BioData, GeolData, GravData, MagnData, and so on). There is another table, the main one, named Product that store...

Query a PostgreSQL view created by SQLAcodegen

I have a useful PostgreSQL view, generated by a JOIN query: \d very_useful_view; View "public.very_useful_view" Column | Type | Modifiers -------------+-------------+----------- ...

Generating models for Flask-AppBuilder using flask-sqlqcodegen

I'm a beginner in Python and Flask ecosystems, trying to create a small proof-of-concept Web application for a research project. I'm using Debian Linux 7.9, PostgreSQL 9.5, SQLAlchemy (latest) and...

Pros and Cons of manually creating an ORM for an existing database?

What are the pros and cons of manually creating an ORM for an existing database vs using database reflection? I'm writing some code using SQLAlchemy to access a pre-existing database. I know I can...

sqlalchemy.exc.AmbiguousForeignKeysError after Inheritance

I'm using sqlacodegen for reflecting a bunch of tables from my database. And i'm getting the following error: sqlalchemy.exc.AmbiguousForeignKeysError: Can't determine join between 'Employee' and...

get classes with tablename associated sqlalchemy

I have a file EE_log_declarative.py with all the classes declared, generated by sqlacodegen engine --outfile declarative_model.py, that looks like the below, which imports as well all the data...

Forcing autoincrement on Numeric primary key with Sqlalchemy and SQL Server

I have an existing SQL Server (2012) DB with many tables having a primary key of Numeric(9, 0) type. For all intents and purposes they are integers. The ORM mapping (generated using sqlacodegen)...

Inserting into a table of foreign keys

I'm a SQLAlchemy noob trying to learn by writing a small room availability web app. I've normalized out my tables so I have a bunch of reference tables (days of the week, room number, course...

flask-sqlacodegen suports python 3.4?

I am trying to generate a flask-sqlalchemy for an existing mysql db. I used the following command flask-sqlacodegen --outfile rcdb.py mysql://username:[email protected]/tablename The project uses...

SyntaxError: Invalid character in identifier when importing models generated using sqlacodegen

I am auto-generating tables in postgresql and models are autogenerated using sqlacodegen using names from a list. Some of the names are non-ascii characters. For name 💞aussieBabe💞 which...

sqlacodegen doesn't make any Tables

I'm running a PostgreSQL database on a server and I'm trying to connect to it using SQLAlchemy. I found that sqlacodegen was a good tool to generate the MetaData object automatically along with...

SQlAlchemy: Could not determine join condition between parent/child tables on relationship error message

I've recently used sqlacodegen When I try and run against the generated code it get this message that I've been unable to fix: Could not determine join condition between parent/child tables on...

Telling SqlAlchemy to map a column but not insert or update its values

I have columns in my database that the database manages. I want SqlAlchemy to map these and retrieve their values in the read operation but not send anything to them in the create or update...

Modifying the 'Base' class generated by sqlacodegen

I want to have a parent class for all of my sqlacodegen classes that map to database tables. The code generated by sqlacodegen includes the following: Base = declarative_base() metadata =...

SQLAlchemy session.query(Table) command is too slow. What's wrong with my code?

Try to select all rows in a database table with about 300,000 rows (Tablename = 'test_table', I'm using Aurora Mysql) from sqlalchemy.engine import create_engine, url from sqlalchemy.orm import...

Alembic --automigrate generates an empty commit

Trying to auto generate initial Alembic files. I have a flask app and I need to set up Alembic to keep track of the database. I generated a fresh dbmodels.py file with the current schema...

SQLAlchemy error when inserting into a table whose Primary Key is also a Foreign Key

I'm using SQLAlchemy to interact with a SQL Server database. One of the tables in my database has a primary key which is also a foreign key (modelling an optional one-to-one relationship). Trying...

Flask_SQLAlchemy Reading a New DataBase

I'm trying to use Flask_SQLAlchemy to map an External Database beside the one I have in my app.config['SQLALCHEMY_DATABASE_URI'] where the External Database is a User Input so there's no way i can...

Can't connect to schema with sqlacodegen

I'm trying to generate models using sqlacodegen and as an output I get only tables from public schema. How can I retrive models from all tables and schemas? sqlacodegen --outfile models.py...

Flask-SQLAlchemy import error. "Imported but unused"

I used sqlacodegen to extract the a .py file containing classes of my db tables. I am using pythonanywhere. However for all the imports it is showing that "imported but unused". You can see though...

Installing Python package in offline environment does not find installed dependency

I am trying to install the SQLACodegen package and its dependencies (inflect, setuptools-scm) from source, in an offline environment. Specifically, I have an Anaconda 2020.07 install using Python...

pip3.6 install mysqlclient==1.3.12 fails with error: unknown type name ‘my_bool’; did you mean ‘bool

I have a project that worked on ubuntu 16.04 with python 3.6 but now we are trying to make it run on ubuntu 20.04 with same python version. I need to install all requirements on the venv and...