-
Notifications
You must be signed in to change notification settings - Fork 285
Expand file tree
/
Copy pathseed.py
More file actions
41 lines (35 loc) · 1.11 KB
/
seed.py
File metadata and controls
41 lines (35 loc) · 1.11 KB
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
import psycopg2
try:
connection = psycopg2.connect(user = "Abdi",
password = "",
host = "localhost",
port = "5432",
database = "twitter")
cursor = connection.cursor()
# cursor.execute('''
# INSERT INTO users (id, name) VALUES
# (11,'User1'),
# (12,'User2'),
# (13,'User3'),
# (14,'User4'),
# (15,'User5');
# ''')
for i in range(400000):
cursor.execute('''
INSERT INTO tweet (user_id, content) VALUES
(11, 'sdfsdfsdfsdf'),
(12, 'dfsfsdfs'),
(13, 'sdfsfsdk'),
(14, 'sfsdfwerwesdjfs'),
(15, 'sfdsfsdfsdfdw');
''')
connection.commit()
print("You did it\n")
except (Exception, psycopg2.Error) as error :
print ("Error while connecting to PostgreSQL", error)
finally:
#closing database connection.
if(connection):
cursor.close()
connection.close()
print("PostgreSQL connection is closed")