-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.py
More file actions
85 lines (68 loc) · 1.52 KB
/
test.py
File metadata and controls
85 lines (68 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
__author__ = 'Alejandro Esquiva Rodriguez'
from aarpy.AARConnector import AARConnector
#AAR Instance
##Create instance via URL
AAR = AARConnector(url="http://automaticapirest.info/demo/getData.php?t=Country&c=Code,Name&l=0,5")
##Create instance via parameters
AAR = AARConnector(domain="http://automaticapirest.info/demo/",table="Country",columns="Name",orderby="Name",limit="10",where="Name:'Albania'")
#Get all the json
jsondata = AAR.getJson()
'''
print(jsondata)
##########################
{'dbInfo': ['Code', 'Name'], 'data': [{'1': 'Aruba', 'Code': 'ABW', '0': 'ABW', 'Name': 'Aruba'}, {'1': 'Afghanistan', 'Code': 'AFG', '0': 'AFG', 'Name': 'Afghanistan'}, {'1': 'Angola', 'Code': 'AGO', '0': 'AGO', 'Name': 'Angola'}, {'1': 'Anguilla', 'Code': 'AIA', '0': 'AIA', 'Name': 'Anguilla'}, {'1': 'Albania', 'Code': 'ALB', '0': 'ALB', 'Name': 'Albania'}]}
'''
#Get all the data
data = AAR.getData()
#Get query info
dbinfo = AAR.getDBInfo()
#Output a specific data
#Name in the first row
name = data[0]["Name"]
#OR
name = data[0]["0"]
print(name)
#Print query info
AAR.printDBInfo()
'''
[
"Code",
"Name"
]
'''
#Print Data
AAR.printData()
'''
[
{
"0": "ABW",
"1": "Aruba",
"Code": "ABW",
"Name": "Aruba"
},
{
"0": "AFG",
"1": "Afghanistan",
"Code": "AFG",
"Name": "Afghanistan"
},
{
"0": "AGO",
"1": "Angola",
"Code": "AGO",
"Name": "Angola"
},
{
"0": "AIA",
"1": "Anguilla",
"Code": "AIA",
"Name": "Anguilla"
},
{
"0": "ALB",
"1": "Albania",
"Code": "ALB",
"Name": "Albania"
}
]
'''