Questions tagged [sqlacodegen]

20 questions
10
votes
5 answers

How to run sqlacodegen?

I'm trying to run sqlacodegen to create a SQLAlchemy model from an existing PostgreSQL database. It won't run. When I type sqlacodegen --help I get: Traceback (most recent call last): File "", line 1, in TypeError: bad operand…
GollyJer
  • 23,857
  • 16
  • 106
  • 174
8
votes
1 answer

Sqlacodegen generates mixed models and tables

Executing this command: sqlacodegen --outfile db.py The db.py contains generated tables: t_table1 = Table(...) and classes too: Table2(Base): __tablename__ = 'table2' The problem is that a table is generated in one way only…
Amio.io
  • 20,677
  • 15
  • 82
  • 117
5
votes
1 answer

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 its Tables. But when I try and run sqlacodgen…
naiveai
  • 590
  • 2
  • 14
  • 42
4
votes
0 answers

Sqlacodegen showing Argspec not found

can anyone please help me with it. I was trying to use sqlacodegen with postgresql to autogenerate the database models from my database, but it is constantly showing me this import error >sqlacodegen…
3
votes
2 answers

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 'Sales'; tables have more than one foreign key…
BoreBoar
  • 2,619
  • 4
  • 24
  • 39
3
votes
2 answers

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) ) result = engine.execute(query) row =…
Amio.io
  • 20,677
  • 15
  • 82
  • 117
2
votes
1 answer

How to set default schema through URL in SQLAlchemy.create_engine for postgresql

I tried to make a python models for my flask application with sqlacodegen . and my database is postgresql in AWS_RDS . so I tried like below sqlacodegen postgresql://{RDS_USERNAME}:{RDS_PASSWORD}@{RDS_HOSTNAME}:{RDS_PORT}/{RDS_DB_NAME}' but it just…
runRyan
  • 713
  • 1
  • 5
  • 13
2
votes
1 answer

sqlalcodegen The client cannot connect to the server because the requested instance was not available

Currently I am trying to setup sqlalchemy orm with sql server express The code below works with no issues and outputs correctly: from sqlalchemy import create_engine from sqlalchemy.orm import session, sessionmaker import urllib from dotenv import…
2
votes
1 answer

ORM classes ending with letter "s" are not generated properly

I'm using SQLAlchemy and sqlacodegen to generate ORM classes for my PostgreSQL models. But to my surprise, tables ending with letter "s" are causing issue. For example, I have a table as below employee_status and the ORM class generated for this…
newbie
  • 1,282
  • 3
  • 20
  • 43
2
votes
1 answer

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 created a table aussieBabe_index for which sqlAlchemy model is…
Harwee
  • 1,601
  • 2
  • 21
  • 35
1
vote
0 answers

sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (1059, "Identifier name is too long")

I got this error when I tried to inspect db that I created before. And I used this below command to make existing table as models.py file. flask-sqlacodegen "mysql+pymysql://[DBUser]:[DBPassword]@[DBhost]:3306/[TableName]" > models.py Is there any…
izzy
  • 11
  • 1
1
vote
1 answer

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:password@hostname/tablename The project uses python 3.4. Any clues? ```Traceback (most recent call…
1
vote
1 answer

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 -------------+-------------+----------- tree_id | dom_treeid | title | text …
Adam Matan
  • 128,757
  • 147
  • 397
  • 562
0
votes
0 answers

Use sqlacodegen in Runtime AWS Lambda

I am trying to generate SQLAlchemy classes automatically in runtime using AWS Lambda, but I am facing some issues. I want to use the sqlacodegen package to create the model code from an existing MySQL database. However, when I try to use the…
0
votes
0 answers

sqlalchemy: cannot print objects of a table (infinite loop)

From a large database, I generated the sqlalchemy classes using sqlacodegen. I can open a session but printing the rows of a table results in sort of infinite loop, sqlalchemy just hangs. Here is a much reduced version of the classes to…
user11634
  • 186
  • 2
  • 12
1
2