CData Python Connector for Azure Data Lake Storage

Build 22.0.8462

Querying Data

After connecting with the steps in Connecting, and reflecting some of the metadata with one of the methods in Reflecting Metadata, you can query data using a session object.

Querying Data Using the Query Method

If the mapping class has been prepared, it is used alongside a session object to query the data source. After binding the engine to the session, simply provide the mapping class to the session's query method, as below:

engine = create_engine("adls:///?Schema=ADLSGen2;Account=MyStorageAccount;FileSystem=MyBlobContainer;AccessKey=myAccessKey;")
factory = sessionmaker(bind=engine)
session = factory()
for instance in session.query(Resources).filter_by(Type="FILE"):
	print("Id: ", instance.Id)
	print("FullPath: ", instance.FullPath)
	print("Permission: ", instance.Permission)

Querying Data Using the Execute Method

As an alternative, the session object can also run the query with the execute() method alongside the appropriate Table object. Assuming you have an active session, the below is just as viable:

Resources_table = Resources.metadata.tables["Resources"]
for instance in session.execute( == "FILE")):
	print("Id: ", instance.Id)
	print("FullName: ", instance.Name)
	print("City: ", instance.BillingCity)

Copyright (c) 2023 CData Software, Inc. - All rights reserved.
Build 22.0.8462