created sqlite schema

This commit is contained in:
JesseBot 2019-01-08 06:30:19 +00:00
parent a9a33d9b46
commit f24d968dbf
2 changed files with 51 additions and 9 deletions

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python
# script by jessebot@linux.com to get the bands and do the things
# 1/7/19 -- 2019? D:
import argparse
@ -23,20 +23,15 @@ def main ():
args = parser.parse_args()
print((args.band))
now = datetime.datetime.now()
now = str(datetime.datetime.now())
sqlite3.register_adapter(datetime.datetime, adapt_datetime)
conn = sqlite3.connect('bands.db')
c = conn.cursor()
# Create table
c.execute('''CREATE TABLE bands
(name text, time text)''')
# Insert a row of data
c.execute("INSERT INTO bands VALUES ({0},{1})".format(args.band,
now))
insert = '''INSERT INTO bands VALUES ('{0}','{1}')'''.format(args.band, now)
c.execute(insert)
# Save (commit) the changes
conn.commit()

47
band_names_init.py Executable file
View file

@ -0,0 +1,47 @@
#!/usr/bin/env python
# script by jessebot@linux.com to get the bands and do the things
# 1/7/19 -- 2019? D:
import argparse
import sqlite3
import datetime
import time
def adapt_datetime(ts):
"""
Internet says I need dis
"""
return time.mktime(ts.timetuple())
def main ():
"""
Let's get it on! *cracks whip*
"""
parser = argparse.ArgumentParser(description='Document cool band names.')
parser.add_argument('--band', nargs='?', type=str,
help='a COOL band name')
args = parser.parse_args()
print((args.band))
now = str(datetime.datetime.now())
conn = sqlite3.connect('bands.db')
c = conn.cursor()
# Create table
c.execute('''CREATE TABLE bands (name text, time text)''')
# Insert a row of data
insert = '''INSERT INTO bands VALUES ('{0}','{1}')'''.format(args.band, now)
c.execute(insert)
# Save (commit) the changes
conn.commit()
# We can also close the connection if we are done with it.
# Just be sure any changes have been committed or they will be lost.
conn.close()
if __name__ == "__main__":
main()