Commit 7583b00c by arun.uday

commit2

parent f731d271
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (task7)" project-jdk-type="Python SDK" /> <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (task7subscribe)" project-jdk-type="Python SDK" />
</project> </project>
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<project version="4"> <project version="4">
<component name="ProjectModuleManager"> <component name="ProjectModuleManager">
<modules> <modules>
<module fileurl="file://$PROJECT_DIR$/.idea/task7.iml" filepath="$PROJECT_DIR$/.idea/task7.iml" /> <module fileurl="file://$PROJECT_DIR$/.idea/task7_mqtt_receiver.iml" filepath="$PROJECT_DIR$/.idea/task7_mqtt_receiver.iml" />
</modules> </modules>
</component> </component>
</project> </project>
\ No newline at end of file
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<content url="file://$MODULE_DIR$"> <content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" /> <excludeFolder url="file://$MODULE_DIR$/venv" />
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="jdk" jdkName="Python 3.9 (task7subscribe)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
</component> </component>
</module> </module>
\ No newline at end of file
import uvicorn import uvicorn
from scripts.config.application_config import uvicorn_host, uvicorn_port
# starting the application # starting the application
if __name__ == "__main__": if __name__ == "__main__":
print("Fast API task") print("Fast API task")
uvicorn.run("scripts.services.receiver_app_services_run:app", host="127.0.0.1", port=8001) uvicorn.run("scripts.services.receiver_app_services_run:app", host=uvicorn_host, port=int(uvicorn_port))
...@@ -5,3 +5,13 @@ sub_path = temp/ ...@@ -5,3 +5,13 @@ sub_path = temp/
[file] [file]
file_name_csv = MOCK_DATA.csv file_name_csv = MOCK_DATA.csv
file_name_json = data.json file_name_json = data.json
[mqtt]
topic = topic
mqtt_host = 192.168.0.220
port = 1883
requests = 60
[uvicorn]
uvicorn_host = 127.0.0.1
uvicorn_port = 8001
...@@ -10,6 +10,17 @@ base_path = config.get("path", 'base_path') ...@@ -10,6 +10,17 @@ base_path = config.get("path", 'base_path')
sub_path = config.get("path", "sub_path") sub_path = config.get("path", "sub_path")
# mqtt
topic_name = config.get("mqtt", "topic")
mqtt_host = config.get("mqtt", "mqtt_host")
port = config.get("mqtt", "port")
request_no = config.get("mqtt", "requests")
# uvicorn
uvicorn_host = config.get("uvicorn", "uvicorn_host")
uvicorn_port = config.get("uvicorn", "uvicorn_port")
# file name # file name
file_name_csv = config.get("file", "file_name_csv") file_name_csv = config.get("file", "file_name_csv")
file_name_json = config.get("file", "file_name_json") file_name_json = config.get("file", "file_name_json")
......
import sqlite3
connection_db = sqlite3.connect('user_details.db')
import json
import pandas as pd
from scripts.database.mysqlite_connect import connection_db
from scripts.utilis.operations_db import SqliteOperations
def on_connect(client, m, c, rc):
print("Connected with result code " + str(rc))
client.subscribe("topic")
def on_message(m, c, msg):
payload_decoded = msg.payload.decode('utf-8')
json_data = json.loads(payload_decoded)
data_list = list(json_data.values())
frames = pd.DataFrame(data_list, index=None)
obj_db = SqliteOperations()
connection = obj_db.create_db(connection_db)
connection = obj_db.insert_db(connection, frames)
data_fetched = obj_db.fetch_data(connection)
print(data_fetched)
import sqlite3 import paho.mqtt.client as mqtt
from fastapi import FastAPI
import json import json
import pandas as pd import pandas as pd
import paho.mqtt.client as mqtt from scripts.config.application_config import topic_name, mqtt_host, port, request_no
from fastapi import FastAPI from scripts.core.handlers.display_data import display_fetched_data
from scripts.utilis.operations_db import SqliteOperations
# This is the Subscriber # This is the Subscriber
...@@ -12,43 +14,28 @@ app = FastAPI() ...@@ -12,43 +14,28 @@ app = FastAPI()
@app.get("/") @app.get("/")
def receiver(): def receiver():
def on_connect(client, user, check, rc): def on_connect(client_name, userdata, flags, rc):
print(userdata, " ", flags)
print("Connected with result code " + str(rc)) print("Connected with result code " + str(rc))
client.subscribe("topic") client_name.subscribe(topic_name)
def on_message(user, check, msg): def on_message(client_name, userdata, msg):
try: print(client_name, " ", userdata)
payload_decoded = msg.payload.decode('utf-8') # decoding the msg to string
json_data = json.loads(payload_decoded) payload_decoded = msg.payload.decode('utf-8')
data_list = list(json_data.values()) json_data = json.loads(payload_decoded)
frames = pd.DataFrame(data_list, index=None) # decoded msg to list
conn = sqlite3.connect('test.db') data_list = list(json_data.values())
conn.execute('''CREATE TABLE IF NOT EXISTS details # list to dataframe
(ID INT PRIMARY KEY NOT NULL, frames = pd.DataFrame(data_list, index=None)
FIRSTNAME TEXT NOT NULL, obj_db = SqliteOperations()
LASTNAME TEXT NOT NULL);''') # inserting the data to table
frames.to_sql('details', conn, if_exists='replace') obj_db.insert_db(frames)
conn.commit() # fetching the data
data_fetched = obj_db.fetch_data()
# Create a cursor display_fetched_data(data_fetched)
cursor = conn.cursor() client = mqtt.Client()
client.connect(mqtt_host, int(port), int(request_no))
# Execute a SELECT statement to fetch data from the "employees" table client.on_connect = on_connect
cursor.execute("SELECT * FROM details") client.on_message = on_message
client.loop_forever()
# Fetch all the rows as a list of tuples
rows = cursor.fetchall()
# Iterate through the rows and print the data
for row in rows:
print(row)
except Exception as e:
print(e)
client = mqtt.Client()
client.connect("192.168.0.220", 1883, 60)
client.on_connect = on_connect
client.on_message = on_message
client.loop_forever()
id,first_name,last_name,email,Address
1,Maurita,Helks,mhelks0@parallels.com,PO Box 3203
2,Prisca,Baxstar,pbaxstar1@whitehouse.gov,20th Floor
3,Camellia,Gallop,cgallop2@comsenz.com,5th Floor
4,Kingston,Keightley,kkeightley3@rediff.com,Suite 35
5,Suzie,Tredgold,stredgold4@myspace.com,PO Box 76402
6,Ade,Coonihan,acoonihan5@stanford.edu,Apt 376
7,Candida,Kobiela,ckobiela6@jiathis.com,10th Floor
8,Karee,Marty,kmarty7@auda.org.au,Suite 75
9,Granville,Weathey,gweathey8@bloglovin.com,2nd Floor
10,Letty,Brecher,lbrecher9@posterous.com,3rd Floor
11,Tam,Graal,tgraala@dmoz.org,Apt 525
12,Dusty,Causbey,dcausbeyb@drupal.org,Apt 1003
13,Kath,Chattey,kchatteyc@smugmug.com,Apt 1074
14,Rutter,Wattins,rwattinsd@hhs.gov,Room 1920
15,Simonette,Gledstane,sgledstanee@nytimes.com,20th Floor
16,Cassey,Gerrelt,cgerreltf@scribd.com,12th Floor
17,Paige,O'Henery,poheneryg@nature.com,Apt 1111
18,Tabbie,Trever,ttreverh@ask.com,20th Floor
19,Hoebart,Valder,hvalderi@tripod.com,5th Floor
20,Margie,Stollenbecker,mstollenbeckerj@fema.gov,Apt 531
21,Bobby,Beet,bbeetk@odnoklassniki.ru,20th Floor
22,Obie,Le Blanc,oleblancl@bravesites.com,Room 832
23,Alyosha,Ruffli,arufflim@bandcamp.com,Suite 14
24,Syman,Granger,sgrangern@bbb.org,PO Box 19521
25,Slade,Weller,swellero@livejournal.com,Room 1911
26,Robina,Rate,rratep@ask.com,Apt 917
27,Karon,Liveley,kliveleyq@tinypic.com,3rd Floor
28,Patty,McGeouch,pmcgeouchr@paginegialle.it,11th Floor
29,Osborn,Ferriday,oferridays@slashdot.org,Room 1474
30,Ellsworth,Dundin,edundint@wikispaces.com,PO Box 17827
31,Mitch,Stetson,mstetsonu@linkedin.com,Apt 603
32,Hardy,Swansbury,hswansburyv@google.it,Apt 1802
33,Nikolas,Telling,ntellingw@ocn.ne.jp,Room 148
34,Gladi,Florey,gfloreyx@dropbox.com,Suite 55
35,Adela,Overbury,aoverburyy@tinyurl.com,4th Floor
36,Evie,McFfaden,emcffadenz@scribd.com,Suite 88
37,Baldwin,Reaman,breaman10@booking.com,Suite 71
38,Beckie,Leadley,bleadley11@blogs.com,Apt 1592
39,Bendick,Kubes,bkubes12@latimes.com,Room 769
40,Huntlee,Mazzeo,hmazzeo13@columbia.edu,Apt 1564
41,Vally,Dzenisenka,vdzenisenka14@themeforest.net,PO Box 96195
42,Lethia,Bolden,lbolden15@yandex.ru,Suite 80
43,Odille,Chataignier,ochataignier16@slate.com,PO Box 73001
44,Cy,Wescott,cwescott17@reuters.com,17th Floor
45,Darnell,Jays,djays18@yellowbook.com,Room 1722
46,Mikael,Wickwar,mwickwar19@bloglines.com,Room 1780
47,Marguerite,McGahey,mmcgahey1a@1688.com,Room 243
48,Jessie,Gaskill,jgaskill1b@angelfire.com,Suite 98
49,Gardiner,Bestall,gbestall1c@cloudflare.com,17th Floor
50,Jo-ann,Rickett,jrickett1d@live.com,Room 903
51,Gavra,Moquin,gmoquin1e@quantcast.com,Room 1139
52,Dylan,Slewcock,dslewcock1f@trellian.com,Apt 1256
53,Danyette,Coolson,dcoolson1g@biglobe.ne.jp,Apt 452
54,Roderich,Ashworth,rashworth1h@163.com,Apt 1416
55,Hildagarde,Haucke,hhaucke1i@ox.ac.uk,Suite 7
56,Darlleen,Bearsmore,dbearsmore1j@google.com,Suite 43
57,Wilmette,Bedwell,wbedwell1k@weebly.com,Suite 65
58,Neville,Swapp,nswapp1l@ocn.ne.jp,Apt 1054
59,Norene,Kopacek,nkopacek1m@domainmarket.com,Suite 38
60,Aubert,Streeting,astreeting1n@cocolog-nifty.com,Suite 82
61,Katrine,Easson,keasson1o@bizjournals.com,Room 1306
62,Celle,Elgie,celgie1p@sciencedirect.com,16th Floor
63,Alvan,Curtin,acurtin1q@booking.com,16th Floor
64,Cornela,Roder,croder1r@google.pl,2nd Floor
65,Wanids,Dansie,wdansie1s@fc2.com,18th Floor
66,Kip,Fillon,kfillon1t@imgur.com,Suite 82
67,Holmes,Kidstoun,hkidstoun1u@usnews.com,Apt 17
68,Freddy,Featherstone,ffeatherstone1v@parallels.com,13th Floor
69,Gusella,Jodlkowski,gjodlkowski1w@chronoengine.com,Apt 515
70,Marietta,Circuit,mcircuit1x@nydailynews.com,18th Floor
71,Brander,Hackley,bhackley1y@drupal.org,Suite 91
72,Nikola,Hughes,nhughes1z@elegantthemes.com,Suite 34
73,Krisha,Aberkirder,kaberkirder20@blogs.com,Suite 70
74,Shina,Meriott,smeriott21@rakuten.co.jp,18th Floor
75,Debra,Sproat,dsproat22@wikia.com,Apt 1650
76,Dunc,Wallworke,dwallworke23@devhub.com,PO Box 58145
77,Rivalee,Gonnet,rgonnet24@oracle.com,Suite 97
78,Regine,Keling,rkeling25@edublogs.org,Room 1519
79,Ashla,Fair,afair26@ucla.edu,Apt 1213
80,Arabela,Theakston,atheakston27@nsw.gov.au,Apt 1277
81,Barney,Grimsdale,bgrimsdale28@reddit.com,PO Box 144
82,Lucho,Braunlein,lbraunlein29@cisco.com,PO Box 26380
83,Jania,Eldredge,jeldredge2a@bloglovin.com,Suite 3
84,Hector,Remer,hremer2b@va.gov,Suite 51
85,Hans,Cantrell,hcantrell2c@bbb.org,Apt 1834
86,Jacquelynn,Kuhne,jkuhne2d@unc.edu,PO Box 70594
87,Way,Moogan,wmoogan2e@chronoengine.com,PO Box 51805
88,Janenna,Costa,jcosta2f@symantec.com,Room 1115
89,Hermine,Bridywater,hbridywater2g@weibo.com,13th Floor
90,Claudette,Highman,chighman2h@ftc.gov,Room 1359
91,Reinhold,Bromehed,rbromehed2i@cargocollective.com,9th Floor
92,Katleen,Dohmer,kdohmer2j@naver.com,PO Box 73746
93,Kellen,Hull,khull2k@eepurl.com,Apt 1569
94,Chrotoem,Lorincz,clorincz2l@behance.net,PO Box 8905
95,Worth,Putton,wputton2m@qq.com,PO Box 91027
96,Luce,Lyford,llyford2n@nps.gov,Room 739
97,Van,Warre,vwarre2o@zimbio.com,Room 1771
98,Kikelia,Benardette,kbenardette2p@vkontakte.ru,PO Box 74859
99,Fabio,Grigoli,fgrigoli2q@plala.or.jp,Apt 1785
100,Rhodia,Batch,rbatch2r@alibaba.com,Room 1597
[
{
"id": 1,
"first_name": "Maurita",
"last_name": "Helks",
"email": "mhelks0@parallels.com",
"Address": "PO Box 3203"
},
{
"id": 2,
"first_name": "Prisca",
"last_name": "Baxstar",
"email": "pbaxstar1@whitehouse.gov",
"Address": "20th Floor"
},
{
"id": 3,
"first_name": "Camellia",
"last_name": "Gallop",
"email": "cgallop2@comsenz.com",
"Address": "5th Floor"
},
{
"id": 4,
"first_name": "Kingston",
"last_name": "Keightley",
"email": "kkeightley3@rediff.com",
"Address": "Suite 35"
},
{
"id": 5,
"first_name": "Suzie",
"last_name": "Tredgold",
"email": "stredgold4@myspace.com",
"Address": "PO Box 76402"
},
{
"id": 6,
"first_name": "Ade",
"last_name": "Coonihan",
"email": "acoonihan5@stanford.edu",
"Address": "Apt 376"
},
{
"id": 7,
"first_name": "Candida",
"last_name": "Kobiela",
"email": "ckobiela6@jiathis.com",
"Address": "10th Floor"
},
{
"id": 8,
"first_name": "Karee",
"last_name": "Marty",
"email": "kmarty7@auda.org.au",
"Address": "Suite 75"
},
{
"id": 9,
"first_name": "Granville",
"last_name": "Weathey",
"email": "gweathey8@bloglovin.com",
"Address": "2nd Floor"
},
{
"id": 10,
"first_name": "Letty",
"last_name": "Brecher",
"email": "lbrecher9@posterous.com",
"Address": "3rd Floor"
},
{
"id": 11,
"first_name": "Tam",
"last_name": "Graal",
"email": "tgraala@dmoz.org",
"Address": "Apt 525"
},
{
"id": 12,
"first_name": "Dusty",
"last_name": "Causbey",
"email": "dcausbeyb@drupal.org",
"Address": "Apt 1003"
},
{
"id": 13,
"first_name": "Kath",
"last_name": "Chattey",
"email": "kchatteyc@smugmug.com",
"Address": "Apt 1074"
},
{
"id": 14,
"first_name": "Rutter",
"last_name": "Wattins",
"email": "rwattinsd@hhs.gov",
"Address": "Room 1920"
},
{
"id": 15,
"first_name": "Simonette",
"last_name": "Gledstane",
"email": "sgledstanee@nytimes.com",
"Address": "20th Floor"
},
{
"id": 16,
"first_name": "Cassey",
"last_name": "Gerrelt",
"email": "cgerreltf@scribd.com",
"Address": "12th Floor"
},
{
"id": 17,
"first_name": "Paige",
"last_name": "O'Henery",
"email": "poheneryg@nature.com",
"Address": "Apt 1111"
},
{
"id": 18,
"first_name": "Tabbie",
"last_name": "Trever",
"email": "ttreverh@ask.com",
"Address": "20th Floor"
},
{
"id": 19,
"first_name": "Hoebart",
"last_name": "Valder",
"email": "hvalderi@tripod.com",
"Address": "5th Floor"
},
{
"id": 20,
"first_name": "Margie",
"last_name": "Stollenbecker",
"email": "mstollenbeckerj@fema.gov",
"Address": "Apt 531"
},
{
"id": 21,
"first_name": "Bobby",
"last_name": "Beet",
"email": "bbeetk@odnoklassniki.ru",
"Address": "20th Floor"
},
{
"id": 22,
"first_name": "Obie",
"last_name": "Le Blanc",
"email": "oleblancl@bravesites.com",
"Address": "Room 832"
},
{
"id": 23,
"first_name": "Alyosha",
"last_name": "Ruffli",
"email": "arufflim@bandcamp.com",
"Address": "Suite 14"
},
{
"id": 24,
"first_name": "Syman",
"last_name": "Granger",
"email": "sgrangern@bbb.org",
"Address": "PO Box 19521"
},
{
"id": 25,
"first_name": "Slade",
"last_name": "Weller",
"email": "swellero@livejournal.com",
"Address": "Room 1911"
},
{
"id": 26,
"first_name": "Robina",
"last_name": "Rate",
"email": "rratep@ask.com",
"Address": "Apt 917"
},
{
"id": 27,
"first_name": "Karon",
"last_name": "Liveley",
"email": "kliveleyq@tinypic.com",
"Address": "3rd Floor"
},
{
"id": 28,
"first_name": "Patty",
"last_name": "McGeouch",
"email": "pmcgeouchr@paginegialle.it",
"Address": "11th Floor"
},
{
"id": 29,
"first_name": "Osborn",
"last_name": "Ferriday",
"email": "oferridays@slashdot.org",
"Address": "Room 1474"
},
{
"id": 30,
"first_name": "Ellsworth",
"last_name": "Dundin",
"email": "edundint@wikispaces.com",
"Address": "PO Box 17827"
},
{
"id": 31,
"first_name": "Mitch",
"last_name": "Stetson",
"email": "mstetsonu@linkedin.com",
"Address": "Apt 603"
},
{
"id": 32,
"first_name": "Hardy",
"last_name": "Swansbury",
"email": "hswansburyv@google.it",
"Address": "Apt 1802"
},
{
"id": 33,
"first_name": "Nikolas",
"last_name": "Telling",
"email": "ntellingw@ocn.ne.jp",
"Address": "Room 148"
},
{
"id": 34,
"first_name": "Gladi",
"last_name": "Florey",
"email": "gfloreyx@dropbox.com",
"Address": "Suite 55"
},
{
"id": 35,
"first_name": "Adela",
"last_name": "Overbury",
"email": "aoverburyy@tinyurl.com",
"Address": "4th Floor"
},
{
"id": 36,
"first_name": "Evie",
"last_name": "McFfaden",
"email": "emcffadenz@scribd.com",
"Address": "Suite 88"
},
{
"id": 37,
"first_name": "Baldwin",
"last_name": "Reaman",
"email": "breaman10@booking.com",
"Address": "Suite 71"
},
{
"id": 38,
"first_name": "Beckie",
"last_name": "Leadley",
"email": "bleadley11@blogs.com",
"Address": "Apt 1592"
},
{
"id": 39,
"first_name": "Bendick",
"last_name": "Kubes",
"email": "bkubes12@latimes.com",
"Address": "Room 769"
},
{
"id": 40,
"first_name": "Huntlee",
"last_name": "Mazzeo",
"email": "hmazzeo13@columbia.edu",
"Address": "Apt 1564"
},
{
"id": 41,
"first_name": "Vally",
"last_name": "Dzenisenka",
"email": "vdzenisenka14@themeforest.net",
"Address": "PO Box 96195"
},
{
"id": 42,
"first_name": "Lethia",
"last_name": "Bolden",
"email": "lbolden15@yandex.ru",
"Address": "Suite 80"
},
{
"id": 43,
"first_name": "Odille",
"last_name": "Chataignier",
"email": "ochataignier16@slate.com",
"Address": "PO Box 73001"
},
{
"id": 44,
"first_name": "Cy",
"last_name": "Wescott",
"email": "cwescott17@reuters.com",
"Address": "17th Floor"
},
{
"id": 45,
"first_name": "Darnell",
"last_name": "Jays",
"email": "djays18@yellowbook.com",
"Address": "Room 1722"
},
{
"id": 46,
"first_name": "Mikael",
"last_name": "Wickwar",
"email": "mwickwar19@bloglines.com",
"Address": "Room 1780"
},
{
"id": 47,
"first_name": "Marguerite",
"last_name": "McGahey",
"email": "mmcgahey1a@1688.com",
"Address": "Room 243"
},
{
"id": 48,
"first_name": "Jessie",
"last_name": "Gaskill",
"email": "jgaskill1b@angelfire.com",
"Address": "Suite 98"
},
{
"id": 49,
"first_name": "Gardiner",
"last_name": "Bestall",
"email": "gbestall1c@cloudflare.com",
"Address": "17th Floor"
},
{
"id": 50,
"first_name": "Jo-ann",
"last_name": "Rickett",
"email": "jrickett1d@live.com",
"Address": "Room 903"
},
{
"id": 51,
"first_name": "Gavra",
"last_name": "Moquin",
"email": "gmoquin1e@quantcast.com",
"Address": "Room 1139"
},
{
"id": 52,
"first_name": "Dylan",
"last_name": "Slewcock",
"email": "dslewcock1f@trellian.com",
"Address": "Apt 1256"
},
{
"id": 53,
"first_name": "Danyette",
"last_name": "Coolson",
"email": "dcoolson1g@biglobe.ne.jp",
"Address": "Apt 452"
},
{
"id": 54,
"first_name": "Roderich",
"last_name": "Ashworth",
"email": "rashworth1h@163.com",
"Address": "Apt 1416"
},
{
"id": 55,
"first_name": "Hildagarde",
"last_name": "Haucke",
"email": "hhaucke1i@ox.ac.uk",
"Address": "Suite 7"
},
{
"id": 56,
"first_name": "Darlleen",
"last_name": "Bearsmore",
"email": "dbearsmore1j@google.com",
"Address": "Suite 43"
},
{
"id": 57,
"first_name": "Wilmette",
"last_name": "Bedwell",
"email": "wbedwell1k@weebly.com",
"Address": "Suite 65"
},
{
"id": 58,
"first_name": "Neville",
"last_name": "Swapp",
"email": "nswapp1l@ocn.ne.jp",
"Address": "Apt 1054"
},
{
"id": 59,
"first_name": "Norene",
"last_name": "Kopacek",
"email": "nkopacek1m@domainmarket.com",
"Address": "Suite 38"
},
{
"id": 60,
"first_name": "Aubert",
"last_name": "Streeting",
"email": "astreeting1n@cocolog-nifty.com",
"Address": "Suite 82"
},
{
"id": 61,
"first_name": "Katrine",
"last_name": "Easson",
"email": "keasson1o@bizjournals.com",
"Address": "Room 1306"
},
{
"id": 62,
"first_name": "Celle",
"last_name": "Elgie",
"email": "celgie1p@sciencedirect.com",
"Address": "16th Floor"
},
{
"id": 63,
"first_name": "Alvan",
"last_name": "Curtin",
"email": "acurtin1q@booking.com",
"Address": "16th Floor"
},
{
"id": 64,
"first_name": "Cornela",
"last_name": "Roder",
"email": "croder1r@google.pl",
"Address": "2nd Floor"
},
{
"id": 65,
"first_name": "Wanids",
"last_name": "Dansie",
"email": "wdansie1s@fc2.com",
"Address": "18th Floor"
},
{
"id": 66,
"first_name": "Kip",
"last_name": "Fillon",
"email": "kfillon1t@imgur.com",
"Address": "Suite 82"
},
{
"id": 67,
"first_name": "Holmes",
"last_name": "Kidstoun",
"email": "hkidstoun1u@usnews.com",
"Address": "Apt 17"
},
{
"id": 68,
"first_name": "Freddy",
"last_name": "Featherstone",
"email": "ffeatherstone1v@parallels.com",
"Address": "13th Floor"
},
{
"id": 69,
"first_name": "Gusella",
"last_name": "Jodlkowski",
"email": "gjodlkowski1w@chronoengine.com",
"Address": "Apt 515"
},
{
"id": 70,
"first_name": "Marietta",
"last_name": "Circuit",
"email": "mcircuit1x@nydailynews.com",
"Address": "18th Floor"
},
{
"id": 71,
"first_name": "Brander",
"last_name": "Hackley",
"email": "bhackley1y@drupal.org",
"Address": "Suite 91"
},
{
"id": 72,
"first_name": "Nikola",
"last_name": "Hughes",
"email": "nhughes1z@elegantthemes.com",
"Address": "Suite 34"
},
{
"id": 73,
"first_name": "Krisha",
"last_name": "Aberkirder",
"email": "kaberkirder20@blogs.com",
"Address": "Suite 70"
},
{
"id": 74,
"first_name": "Shina",
"last_name": "Meriott",
"email": "smeriott21@rakuten.co.jp",
"Address": "18th Floor"
},
{
"id": 75,
"first_name": "Debra",
"last_name": "Sproat",
"email": "dsproat22@wikia.com",
"Address": "Apt 1650"
},
{
"id": 76,
"first_name": "Dunc",
"last_name": "Wallworke",
"email": "dwallworke23@devhub.com",
"Address": "PO Box 58145"
},
{
"id": 77,
"first_name": "Rivalee",
"last_name": "Gonnet",
"email": "rgonnet24@oracle.com",
"Address": "Suite 97"
},
{
"id": 78,
"first_name": "Regine",
"last_name": "Keling",
"email": "rkeling25@edublogs.org",
"Address": "Room 1519"
},
{
"id": 79,
"first_name": "Ashla",
"last_name": "Fair",
"email": "afair26@ucla.edu",
"Address": "Apt 1213"
},
{
"id": 80,
"first_name": "Arabela",
"last_name": "Theakston",
"email": "atheakston27@nsw.gov.au",
"Address": "Apt 1277"
},
{
"id": 81,
"first_name": "Barney",
"last_name": "Grimsdale",
"email": "bgrimsdale28@reddit.com",
"Address": "PO Box 144"
},
{
"id": 82,
"first_name": "Lucho",
"last_name": "Braunlein",
"email": "lbraunlein29@cisco.com",
"Address": "PO Box 26380"
},
{
"id": 83,
"first_name": "Jania",
"last_name": "Eldredge",
"email": "jeldredge2a@bloglovin.com",
"Address": "Suite 3"
},
{
"id": 84,
"first_name": "Hector",
"last_name": "Remer",
"email": "hremer2b@va.gov",
"Address": "Suite 51"
},
{
"id": 85,
"first_name": "Hans",
"last_name": "Cantrell",
"email": "hcantrell2c@bbb.org",
"Address": "Apt 1834"
},
{
"id": 86,
"first_name": "Jacquelynn",
"last_name": "Kuhne",
"email": "jkuhne2d@unc.edu",
"Address": "PO Box 70594"
},
{
"id": 87,
"first_name": "Way",
"last_name": "Moogan",
"email": "wmoogan2e@chronoengine.com",
"Address": "PO Box 51805"
},
{
"id": 88,
"first_name": "Janenna",
"last_name": "Costa",
"email": "jcosta2f@symantec.com",
"Address": "Room 1115"
},
{
"id": 89,
"first_name": "Hermine",
"last_name": "Bridywater",
"email": "hbridywater2g@weibo.com",
"Address": "13th Floor"
},
{
"id": 90,
"first_name": "Claudette",
"last_name": "Highman",
"email": "chighman2h@ftc.gov",
"Address": "Room 1359"
},
{
"id": 91,
"first_name": "Reinhold",
"last_name": "Bromehed",
"email": "rbromehed2i@cargocollective.com",
"Address": "9th Floor"
},
{
"id": 92,
"first_name": "Katleen",
"last_name": "Dohmer",
"email": "kdohmer2j@naver.com",
"Address": "PO Box 73746"
},
{
"id": 93,
"first_name": "Kellen",
"last_name": "Hull",
"email": "khull2k@eepurl.com",
"Address": "Apt 1569"
},
{
"id": 94,
"first_name": "Chrotoem",
"last_name": "Lorincz",
"email": "clorincz2l@behance.net",
"Address": "PO Box 8905"
},
{
"id": 95,
"first_name": "Worth",
"last_name": "Putton",
"email": "wputton2m@qq.com",
"Address": "PO Box 91027"
},
{
"id": 96,
"first_name": "Luce",
"last_name": "Lyford",
"email": "llyford2n@nps.gov",
"Address": "Room 739"
},
{
"id": 97,
"first_name": "Van",
"last_name": "Warre",
"email": "vwarre2o@zimbio.com",
"Address": "Room 1771"
},
{
"id": 98,
"first_name": "Kikelia",
"last_name": "Benardette",
"email": "kbenardette2p@vkontakte.ru",
"Address": "PO Box 74859"
},
{
"id": 99,
"first_name": "Fabio",
"last_name": "Grigoli",
"email": "fgrigoli2q@plala.or.jp",
"Address": "Apt 1785"
},
{
"id": 100,
"first_name": "Rhodia",
"last_name": "Batch",
"email": "rbatch2r@alibaba.com",
"Address": "Room 1597"
}
]
\ No newline at end of file
import sqlite3
class SqliteOperations: class SqliteOperations:
@staticmethod def __init__(self):
def create_db(conn): # connecting to the database
self.conn = sqlite3.connect('user_details.db')
def create_db(self):
try: try:
conn.execute('''CREATE TABLE IF NOT EXISTS details # creating the table
self.conn.execute('''CREATE TABLE IF NOT EXISTS details
(ID INT PRIMARY KEY NOT NULL, (ID INT PRIMARY KEY NOT NULL,
FIRSTNAME TEXT NOT NULL, FIRSTNAME TEXT NOT NULL,
LASTNAME TEXT NOT NULL);''') LASTNAME TEXT NOT NULL);''')
return conn self.conn.close()
except Exception as e: except Exception as e:
print(e) print(e)
@staticmethod def insert_db(self, frames):
def insert_db(conn, frames):
try: try:
frames.to_sql('details', conn, if_exists='replace') # inserting data to table
conn.commit() frames.to_sql('details', self.conn, if_exists='replace')
return conn self.conn.commit()
except Exception as e: except Exception as e:
print(e) print(e)
@staticmethod def fetch_data(self):
def fetch_data(conn):
try: try:
# Create a cursor # Create a cursor
cursor = conn.cursor() cursor = self.conn.cursor()
# Execute a SELECT statement to fetch data from the "employees" table # Execute a SELECT statement to fetch data from the "detaisl" table
cursor.execute("SELECT * FROM details") cursor.execute("SELECT * FROM details")
return cursor return cursor
except Exception as e: except Exception as e:
......
File deleted
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment