Comments (13)
Original comment by kwilcox (Bitbucket: kwilcox, GitHub: kwilcox):
from sqlacodegen.
Original comment by Francisco Puga (Bitbucket: fpuga, GitHub: fpuga):
I will be monitoring the ticket to test it and give feedback when the patch will be ready.
from sqlacodegen.
Original comment by Alex Grönholm (Bitbucket: agronholm, GitHub: agronholm):
Answering my own question: just importing geoalchemy2 is enough. Alright, should be a simple enough change. Expect this in 2.0.
from sqlacodegen.
Original comment by Alex Grönholm (Bitbucket: agronholm, GitHub: agronholm):
How do you propose I do that when sqlacodegen relies on SQLAlchemy's reflection?
from sqlacodegen.
Original comment by Francisco Puga (Bitbucket: fpuga, GitHub: fpuga):
I also think that will be great to be able to create models with the geometry type ( from geoalchemy2 import Geometry
)
I'm using sqlacodegen==1.1.6, SQLAlchemy==1.0.11, GeoAlchemy2==0.2.6. When using this tool a get:
$ sqlacodegen postgresql://...
..../local/lib/python2.7/site-packages/SQLAlchemy-1.0.11-py2.7-linux-x86_64.egg/sqlalchemy/dialects/postgresql/base.py:2505: SAWarning: Did not recognize type 'geometry' of column 'the_geom'
The rest of the models are correctly created but for the 'geometry' columns NullType is used.
#!python
the_geom = Column(NullType, index=True)
It's not a big deal, just search for NullType and replace with the correct values. But it will be useful that sqlacodegen can get the custom types from geoalchemy
from sqlacodegen.
Original comment by Alex Grönholm (Bitbucket: agronholm, GitHub: agronholm):
This needs to be fixed upstream so that the geometry column type is recognized. If this conclusion is wrong, reopen the issue.
from sqlacodegen.
Original comment by Alex Grönholm (Bitbucket: agronholm, GitHub: agronholm):
Has anyone successfully reflected a database with such columns?
from sqlacodegen.
Original comment by Alex Grönholm (Bitbucket: agronholm, GitHub: agronholm):
Release 1.1.6 fixes compatibility with SQLAlchemy 1.0. But it still doesn't have the PostgreSQL geometry types.
from sqlacodegen.
Original comment by Alex Grönholm (Bitbucket: agronholm, GitHub: agronholm):
SQLAlchemy 1.0 broke sqlacodegen. I'll have to fix that. Although, can you point me to the proper SQLAlchemy types that these should map to?
from sqlacodegen.
Original comment by Neil Albrock (Bitbucket: neilalbrock, GitHub: neilalbrock):
I've recently encountered this issue as well. With SQLAlchemy 0.9.9 I get the following:
#!python
/home/atomised/.virtualenvs/importizer/local/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.py:2079: SAWarning: Did not recognize type 'geometry' of column 'geom'
name, format_type, default, notnull, domains, enums, schema)
/home/atomised/.virtualenvs/importizer/local/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.py:2079: SAWarning: Did not recognize type 'geometry' of column 'extent'
name, format_type, default, notnull, domains, enums, schema)
With the latest SQLAlchemy 1.0.4 I get this:
#!python
/home/atomised/.virtualenvs/importizer/local/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.py:2421: SAWarning: Did not recognize type 'geometry' of column 'geom
'
(attype, name))
/home/atomised/.virtualenvs/importizer/local/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.py:2421: SAWarning: Did not recognize type 'geometry' of column 'exte
nt'
(attype, name))
Traceback (most recent call last):
File "/home/atomised/.virtualenvs/importizer/bin/sqlacodegen", line 11, in <module>
sys.exit(main())
File "/home/atomised/.virtualenvs/importizer/local/lib/python2.7/site-packages/sqlacodegen/main.py", line 40, in main
generator = CodeGenerator(metadata, args.noindexes, args.noconstraints, args.nojoined, args.noinflect)
File "/home/atomised/.virtualenvs/importizer/local/lib/python2.7/site-packages/sqlacodegen/codegen.py", line 536, in __init__
model = ModelClass(table, links[table.name], inflect_engine, not nojoined)
File "/home/atomised/.virtualenvs/importizer/local/lib/python2.7/site-packages/sqlacodegen/codegen.py", line 300, in __init__
relationship_ = ManyToOneRelationship(self.name, target_cls, constraint, inflect_engine)
File "/home/atomised/.virtualenvs/importizer/local/lib/python2.7/site-packages/sqlacodegen/codegen.py", line 412, in __init__
colname = constraint.columns[0]
File "/home/atomised/.virtualenvs/importizer/local/lib/python2.7/site-packages/sqlalchemy/util/_collections.py", line 191, in __getitem__
return self._data[key]
KeyError: 0
I hope that helps, it would certainly be good if all Postgres column types could be handled. Let me know if I can offer any assistance.
from sqlacodegen.
Original comment by Alex Grönholm (Bitbucket: agronholm, GitHub: agronholm):
Out of curiosity, does it fail on reflection or in the code generation phase?
from sqlacodegen.
Original comment by Alex Grönholm (Bitbucket: agronholm, GitHub: agronholm):
SQLACodegen does not recognize custom types, only built-in ones. It wouldn't know where to import those from anyway.
from sqlacodegen.
Closing this as it is superseded by #29.
from sqlacodegen.
Related Issues (20)
- Enhancement: Add Support for pgvector extension HOT 2
- SQLModel codegen produces syntax errors HOT 6
- Syntax Error in 3.0.0rc3 HOT 5
- No poetry package which supports SQLAlchemy 2.0 HOT 5
- AssertionError: TypeDecorator implementations require a class-level variable 'impl' HOT 14
- sqlalchemy.exc.OperationalError HOT 6
- Database URL is split on & HOT 1
- No module named 'pkg_resources' HOT 2
- ImportError: cannot import name 'ArgSpec' from 'inspect' HOT 1
- Can we push more versions to PyPi HOT 5
- Using types instead of strings in return values of methods in generators
- Issue when generating Postgres DOMAIN type HOT 2
- Could not assemble any primary key when using the SQLModel generator
- UUID for postgreSQL HOT 1
- Attribute error module 'sqlalchemy' has no attribute '__all__'. Did you mean: '__file__'? for mysql HOT 2
- MySQL DOUBLE(11,2) is converted to Double(11, True)
- Child table ORM classes inheriting from base tables are not generated HOT 5
- Installed on my windows10 python 3.12.4, get incompatible error HOT 3
- Missing many-to-many relationship HOT 1
- Error when reading vector column of pgvector HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sqlacodegen.