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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ecms_api-2.0.1.tar.gz
.
File metadata
- Download URL: ecms_api-2.0.1.tar.gz
- Upload date:
- Size: 10.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d47a390f6302e7aada9fa7df025d39ee5f79e06462b6a55a13826318b1555e9 |
|
MD5 | e341564cb8169c5a9f3204a711ba375e |
|
BLAKE2b-256 | 81db93b04e15a514b09e5ab62cd40899c82e152ad188d85c87491e3c90c6e506 |
File details
Details for the file ecms_api-2.0.1-py3-none-any.whl
.
File metadata
- Download URL: ecms_api-2.0.1-py3-none-any.whl
- Upload date:
- Size: 14.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d4b4a18893bc08760513f1108a8cff84b97636e713a2ad036fd0fd0734c36c63 |
|
MD5 | c1524a5bf5504da86ad882e25d8764a1 |
|
BLAKE2b-256 | 3f8d187842b2f6379ce05c7a1d71a39ae60a7df2c6f882a80d8f2e3b0871c957 |