Skip to content

Instantly share code, notes, and snippets.

@thomaswpp
Created February 9, 2018 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomaswpp/c60e9835f702e72db6ea762a50df5e48 to your computer and use it in GitHub Desktop.
Save thomaswpp/c60e9835f702e72db6ea762a50df5e48 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://doc.scrapy.org/en/latest/topics/item-pipeline.html
import pyodbc
class BlacktagPipeline(object):
def __init__(self):
self.dbpath = "/home/thomas/passticket.mdb"
self.driver = "MDBTools"
self.conn = pyodbc.connect("DRIVER={};DBQ={}".format(self.driver, self.dbpath))
self.conn.autocommit = True;
self.cursor = self.conn.cursor()
def process_item(self, item, spider):
query = "SELECT * FROM tb_users"
#query = "INSERT INTO tb_users (user_id, user_pass, user_ip, user_email) VALUES('userteste', 'userteste', 1, 'testando')"
self.cursor.execute(query)
#self.cursor.tables()
rows = self.cursor.fetchall()
for row in rows:
print (row.table_name)
self.cursor.close()
return item
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment