This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select * from cs621labexam1; | |
--1 | |
select * from cs621labexam1 where char_length(observer) > 9; | |
--2 | |
select * from cs621labexam1 | |
where 1=1 | |
and date_part('month', ts) = 01 | |
and date_part('year', ts) = 2019 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import sqlalchemy | |
# Create the engine to connect to a PostgreSQL database | |
engine = sqlalchemy.create_engine('postgresql://aveek:test1234@localhost:5432/sql-shack-demo') | |
# Read data from the SQL Table | |
data = pd.read_csv('superstore.csv') | |
# Print first few rows of the dataframe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask | |
from flask_restful import Api, Resource, reqparse | |
import pandas as pd | |
app = Flask(__name__) | |
api = Api(app) | |
class Users(Resource): | |
def get(self): | |
data = pd.read_csv('users.csv') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Users(Resource): | |
def get(self): | |
data = pd.read_csv('users.csv') | |
data = data.to_dict('records') | |
return {'data' : data}, 200 | |
def post(self): | |
parser = reqparse.RequestParser() | |
parser.add_argument('name', required=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if __name__ == '__main__': | |
app.run() |
We can make this file beautiful and searchable if this error is corrected: It looks like row 5 should actually have 4 columns, instead of 5. in line 4.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
order,product,qty,amount | |
1,car,2,5000 | |
2,bikes,1,2000 | |
3,cookies,10,80 | |
4,phone,1,5,300 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# imports the JSON library to work in python | |
import json | |
# assign the JSON data to a variable | |
json_data = """{ | |
"data": [ | |
{ | |
"type": "articles", | |
"id": "1", | |
"attributes": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# imports the Pandas library to work in python | |
import pandas as pd | |
# assign the JSON data to a variable | |
json_data = """{ | |
"data": [ | |
{ | |
"type": "articles", | |
"id": "1", | |
"attributes": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# imports the Pandas library to work in python | |
import pandas as pd | |
# Create the data as a list | |
data = [['Bob', 30], ['Fred', 35], ['Nick', 40]] | |
# Load the data as a dataframe | |
df = pd.DataFrame(data=data, columns=['Name','Age']) | |
# Covnert the dataframe to JSON |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
def greet(): | |
print('Hello user') | |
def main(): | |
greet() | |
if __name__ == '__main__': | |
main() |
OlderNewer