-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpg.py
32 lines (19 loc) · 836 Bytes
/
pg.py
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
import psycopg2
import sys, os
## ****** LOAD PSQL DATABASE ***** ##
# Set up a connection to the postgres server.
# conn_string = "host="+ "stats@localhost" +" port="+ "5432" +" dbname="+ "stats" +" user=" + "charlieana" \
# +" password="+ "akk322"
# psycopg2.connect(database='testdb', user='postgres',
# password='s$cret')
con=psycopg2.connect(database='stackoverflow', user='charlieanna',
password='akk322')
print("Connected!")
with con:
cur = con.cursor()
cur.execute("select * from posts where tags like '%<go>%' order by score;")
rows = cur.fetchall()
for row in rows:
print(row)
# create another table so that matching tags to questions become easier.
# fr each question extract the tags and then map the tags to question.s but the table will be huge because of the query.