-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsql.py
More file actions
42 lines (39 loc) · 1008 Bytes
/
sql.py
File metadata and controls
42 lines (39 loc) · 1008 Bytes
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
SELECT_WEBSITE = """
SELECT *
FROM (
SELECT
bg.id,
bg.website,
1 AS type
FROM games bg
WHERE bg.deleted = FALSE
AND bg.domain IS NOT NULL
AND bg.website IS NOT NULL
AND bg.website NOT IN (\'\', \'-\')
AND NOT exists(
SELECT 1
FROM socials t
WHERE t.url = bg.website
)
UNION
SELECT
bo.id,
bo.website,
2 AS type
FROM orgs bo
WHERE bo.deleted = FALSE
AND bo.domain IS NOT NULL
AND bo.website IS NOT NULL
AND bo.website NOT IN (\'\', \'-\')
AND NOT exists(
SELECT 1
FROM socials t
WHERE t.url = bo.website
)
) t
ORDER BY t.type ASC
"""
INSERT_DATA = """
insert into socials (id, url, domain, twitters, error, cdate, mdate)
values (nextval('socials_id_seq'), $1, $2, $3, $4, current_timestamp, current_timestamp);
"""