Comments (3)
The underlying table can have more columns than you describe in SQLAlchemy, so your code will still work (you just won't have access to those new/extra columns).
At minimum, you must define a primary key that is actually unique across rows (and there are ways to use multi-column primary keys when necessary).
from iaccess.
You're doing nothing wrong, but this library is not fully-featured yet, especially in the "reflection" capabilities.
To use this library effectively at the moment, you need to include your table definition in your Python code, either with SQLAlchemy "Core" or "ORM" code.
import sqlalchemy as db
from sqlalchemy import Engine
engine: Engine = db.create_engine('iaccess+pyodbc://sqluser:sqlpass@ipaddress/MYDB?DBQ=DEFAULT_SCHEMA')
connection = engine.connect()
metadata = db.MetaData()
mytable = db.Table( # remove the autoload_with param and define each column
'MYTABLE',
metadata,
db.Column('idcol', db.Integer, primary_key=True),
db.Column('mycol', db.String(30)),
)
query = db.select([mytable]).where(mytable.columns.MYCOL == '1240425')
ResultProxy = connection.execute(query)
ResultSet = ResultProxy.fetchall()
print(ResultSet)
from iaccess.
@soundstripe thank you for the prompt response!
Can I ask you one more thing?
Let's say I have MYTABLE with those 2 columns defined by you, idcol
and mycol
. I have the code you defined above and it works fine.
Now I change the said table so that I add another column, let's say thirdcol
. I will leave my code unchanged (it only has first two columns defined). Will the code break, since the table definition in my code is not 1-to-1 correct anymore?
from iaccess.
Related Issues (3)
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 iaccess.