Skip to content
This repository has been archived by the owner on Mar 14, 2023. It is now read-only.

Commit

Permalink
add welcome table to db (#341)
Browse files Browse the repository at this point in the history
* add welcome table to db

* Rename db

* models: add welcome table

* tests: update db name

* Add welcome_id as primary key & unique

* models: add PK to welcome

* Update example.db

Co-authored-by: Operator873 <operator873@873gear.com>
Co-authored-by: RhinosF1 <rhinosf1@gmail.com>
  • Loading branch information
3 people committed Oct 27, 2020
1 parent 578afa2 commit 9f60564
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
Binary file renamed MirahezeBots/hasan.db → MirahezeBots/example.db
Binary file not shown.
15 changes: 14 additions & 1 deletion tests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,23 @@ def __str__(self):
return NickNames.__str__(self)


class Welcome(Base):
__tablename__ = 'welcome'
welcome_id = Column(Integer, primary_key=True)
nick_id = Column(Integer)
account = Column(String)
channel = Column(String)
timestamp = Column(String)
message = Column(String)

def __str__(self):
return Welcome.__str__(self)


if __name__ == '__main__':
try:
engine = create_engine('sqlite:///{0}'.format(sys.argv[1]), echo=True)
except IndexError:
print('argument not provided')
engine = create_engine('sqlite:///hasan2.db', echo=True)
engine = create_engine('sqlite:///example-model.db', echo=True)
Base.metadata.create_all(engine)
6 changes: 3 additions & 3 deletions tests/test_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@

def test_db_schema_is_same():
original, new = set(), set() # noqa: F841
with sqlite3.connect(os.path.join(PATH, 'hasan.db')) as conn:
with sqlite3.connect(os.path.join(PATH, 'example.db')) as conn:
conn.text_factory = str
res = conn.execute("SELECT name FROM sqlite_master WHERE type='table';")
[original.add(tbl[0]) for tbl in res if not tbl[0] == 'nick_ids' and not tbl[0] == 'sqlite_sequence']

try:
os.unlink(os.path.join(PATH, "hasan2.db"))
os.unlink(os.path.join(PATH, "example-model.db"))
except FileNotFoundError:
pass

engine = create_engine('sqlite:///{0}'.format(os.path.join(PATH, "..", "hasan2.db")))
engine = create_engine('sqlite:///{0}'.format(os.path.join(PATH, "..", "example-model.db")))
models.Base.metadata.create_all(bind=engine)
assert original == set(engine.table_names())

Expand Down

0 comments on commit 9f60564

Please sign in to comment.