Skip to main content

A python integration to allow for quickly sending queries directly to the as400

Project description

ECMS-API

ECMS-API is a query wrapper that allows for querying the AS400 directly

Authors

Johnny Whitworth (@Poseidon-dev)

How to use Examples

SQLQuery is a class factory that takes in a table object. The methods in SQLQuery (select, update, insert) return a class type of the same name with the table being passed as a paramter.

It should be noted that the tables themselves are objects, and not strings.

Tables can be found in ecmsapi

Select

table = SQLQuery(HRTEMP)
query = table.select()

query.filters(employeeno=12345, companyno=50, divisionno=2)
query.columns(['CompanyNo', 'DivisionNo', 'EmployeeNo', 'City'])
query.order(by='City')
query.head()

response = query.query()

Returns the command and corresponding values:

SELECT
COMPANYNO, DIVISIONNO, EMPLOYEENO, CITY FROM CMSFIL.HRTEMP
WHERE EMPLOYEENO = '12345' AND COMPANYNO = '50' AND DIVISIONNO = '2' ORDER BY City ASC LIMIT 10

The select method also allows for queried data to be saved as an excel doc using .to_excel() rather than .query()

Update

table = SQLQuery(HRTEMP)
query = table.update()

query.sets(City='SomeCity', companyno=50)
query.filters(employeeno=12345)
query.query()

Will execute the following:

UPDATE
CMSFIL.HRTEMP
SET CITY = 'SomeCity' , COMPANYNO = '50' WHERE EMPLOYEENO = '12345'

Insert

table = SQLQuery(HRTCPR)
query = table.update()

query.sets(City='SomeCity', companyno=50)
query.filters(employeeno=12345)
query.query()

Will execute the following:

INSERT INTO
CMSFIL.HRTEMP
("CITY", "COMPANYNO") VALUES ('SomeCity', '50')

Support

If you need some help for something, please reach out to me directly or submit an issue and I'll get to it as soon as I can

Site

https://poseidon-dev.github.io/ecms-api/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ecms_api-2.0.1.tar.gz (10.1 kB view hashes)

Uploaded Source

Built Distribution

ecms_api-2.0.1-py3-none-any.whl (14.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page