@@ -0,0 +1,1322 @@
+from random_words import RandomWords%0Afrom faker import Factory%0Aimport random%0Aimport sqlite3%0A%0ANUM_GENERATE = 100%0A%0ACATEGORIES = %5B'miscellaneous', 'appliance', 'bedding', 'toys', 'books', 'clothing',%0A%09'seasonal', 'electronics', 'household', 'kitchen', 'sports'%5D%0A%0Adef generate_postings(count):%0A%09postings = %5B%5D%0A%09for i in range(count):%0A%09%09faker = Factory.create()%0A%09%09rw = RandomWords()%0A%0A%09%09posting = %7B%0A%09%09%09'name': faker.name(),%0A%09%09%09'address': faker.city() + %22, %22 + faker.state(),%0A%09%09%09'email': faker.email(),%0A%09%09%09'phone': random.randint(1000000000, 9999999999),%0A%09%09%09'title': %22 %22.join(rw.random_words(count=2)),%0A%09%09%09'description': %22 %22.join(rw.random_words(count=8)),%0A%09%09%09'category': random.choice(CATEGORIES),%0A%09%09%7D%0A%09%09postings.append(posting)%0A%09return postings%0A%0A%0Adef write_database(postings):%0A%09conn=sqlite3.connect('givegetgreen_db');%0A%09c=conn.cursor()%0A%09for post in postings:%0A%09%09# name email phone address category description title%0A%09%09c.execute('''INSERT INTO posting_posting VALUES (null, '%25s', '%25s', '%25s', '%25s', '%25s', '%25s', '%25s')'''%0A%09%09%09%25 (post%5B'name'%5D, post%5B'email'%5D, post%5B'phone'%5D, post%5B'address'%5D, post%5B'category'%5D, post%5B'description'%5D, post%5B'title'%5D));%0A%09conn.commit()%0A%09conn.close()%0A%09print str(len(postings)) + %22 postings written to database%22%0A%0A%0Aif __name__ == '__main__':%0A%0A%09postings = generate_postings(NUM_GENERATE)%0A%09write_database(postings)

Implement auto generate db postings