Created
February 9, 2018 16:48
-
-
Save thomaswpp/c60e9835f702e72db6ea762a50df5e48 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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