-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabase.py
43 lines (35 loc) · 1.45 KB
/
database.py
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
43
from requests import Session
from sqlalchemy import Column, Integer, String, Numeric,ForeignKey
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from sqlalchemy.orm import relationship
Base = declarative_base()
class Information(Base):
__tablename__ = 'information'
id = Column(Integer, primary_key=True)
title=Column(String(1500))
description=Column(String(1500))
date=Column(String(50))
location=Column(String(1500),nullable=True)
# Here we define columns for the table person
# Notice that each column is also a normal Python instance attribute.
# name = Column(String(250), nullable=False)
# sqlite_autoincrement = True
#
# class Address(Base):
# __tablename__ = 'address'
# # Here we define columns for the table address.
# # Notice that each column is also a normal Python instance attribute.
# id = Column(Integer, primary_key=True)
# street_name = Column(String(250))
# street_number = Column(String(250))
# post_code = Column(String(250), nullable=False)
# person_id = Column(Integer, ForeignKey('person.id'))
# person = relationship(Person)
# Create an engine that stores data in the local directory's
# sqlalchemy_example.db file.
engine = create_engine('sqlite:///crawler1.db')
# Create all tables in the engine. This is equivalent to "Create Table"
# statements in raw SQL.
Base.metadata.create_all(engine)