Esempio n. 1
0
def view():
    conn=pyscopg2.connect("dbname='database' user='******' password='******' host='localhost' port='5432'")
    cur=conn.cursor()
    cur.execute("SELECT * FROM store")
    rows=cur.fetchall()
    conn.close()
    return rows
Esempio n. 2
0
def register_mensagem(assunto, mensagem):
    conn = pyscopg2.connect(DNS)
    cur = conn.cursor()
    cur.execute(SQL, (assunto, mensagem))
    conn.commit()
    cur.close()
    conn.close()

    print('Mensagem registrada')
Esempio n. 3
0
import praw
import config
import pprint
import matplotlib.pyplot as plt
import time
import pyscopg2


reddit = praw.Reddit(username = config.username,
                password = config.password,
                client_id = config.client_id,
                client_secret = config.client_secret,
                user_agent = "naddy's comment reader test v0.1")

conn = pyscopg2.connect("dbname=redditbot user=cmariekirk")
cur = conn.cursor()


"""Code below counts how many times a specified word appears in the top ten
posts of a given subreddit"""
def title_word_count():
    counter = 0
    for submission in reddit.subreddit('coffee').hot(limit=10):
        prc = submission.title.lower()
        if "coffee" in prc:
            counter += 1
    print(counter)

"""Function below will retrieve some basic information from a given subreddit
This function accesses the 'new' category but we can also access
Esempio n. 4
0
def insert(item,quantity,price):
    conn=pyscopg2.connect("dbname='database' user='******' password='******' host='localhost' port='5432'")
    cur=conn.cursor()
    cur.execute("INSERT INTO store VALUES(%s,%s,%s)", (item,quanity,price))
    conn.commit()
    conn.close()
Esempio n. 5
0
def update(quantity,price,item):
    conn=pyscopg2.connect("dbname='database' user='******' password='******' host='localhost' port='5432'")
    cur=conn.cursor()
    cur.execute("UPDATE store SET quantity=%s, price=%s item WHERE item=%s",(quanity,price,item))
    conn.commit()
    conn.close()
Esempio n. 6
0
def delete(item):
    conn=pyscopg2.connect("dbname='database' user='******' password='******' host='localhost' port='5432'")
    cur=conn.cursor()
    cur.execute("DELETE FROM store WHERE item=%s",(item,))
    conn.commit()
    conn.close()
Esempio n. 7
0
def create_table():
    conn=pyscopg2.connect("dbname='database' user='******' password='******' host='localhost' port='5432'")
    cur=conn.cursor()
    cur.execute("CREATE TABLE IF NOT EXISTS store (item TEXT, quantity INTEGER, price REAL)")
    conn.commit()
    conn.close()
Esempio n. 8
0
where code = %s
and year = %s
and sem = %s

select * from curr_courses_by_prof
where code = %s
# --------single result------------------------
import pyscopg2 as ps
import os
import requests
import json
from flask import request, jsonify
from flask import Flask, render_template
from flask_cors import CORS

conn = ps.connect("dbname=project_3 user=postgres password=Ishu@1003")
cur = conn.cursor()
get_oldco="select * from courses where code = %s and year = %s and sem = %s"

get_co="select * from curr_courses where code = %s"

# -----multiple result of courses----

allco_slot="select code,name,slot,credits from courses where code ilike concat('%',%s,'%') and name ilike concat('%',%s,'%') and slot = %s and year = %s and semester = %s"

allco="select code,name,slot,credits from courses where code ilike concat('%',%s,'%') and name ilike concat('%',%s,'%') and year = %s and semester = %s"


curco_slot="select code,name,slot,credits from curr_courses where code ilike concat('%',%s,'%') and name ilike concat('%',%s,'%') and slot = %s"

curco="select code,name,slot,credits from curr_course where code ilike concat('%',%s,'%') and name ilike concat('%',%s,'%')"