From a2c0ffe072bd3b5749c26f6ffacba9cab7ebc61e Mon Sep 17 00:00:00 2001 From: Fabian Externbrink Date: Wed, 5 Jul 2017 17:14:07 +0200 Subject: [PATCH] Add SQLite main --- README.md | 2 +- Tutorial/01 SQLite in Python/__main__.py | 18 ++++++++++++++++++ Tutorial/01 SQLite in Python/sql_fill.py | 14 ++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 Tutorial/01 SQLite in Python/__main__.py create mode 100644 Tutorial/01 SQLite in Python/sql_fill.py diff --git a/README.md b/README.md index ca23ad1..54d4333 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -# OrcID_ \ No newline at end of file +# ORC-Schlange \ No newline at end of file diff --git a/Tutorial/01 SQLite in Python/__main__.py b/Tutorial/01 SQLite in Python/__main__.py new file mode 100644 index 0000000..26e988c --- /dev/null +++ b/Tutorial/01 SQLite in Python/__main__.py @@ -0,0 +1,18 @@ +from sqlite3 import connect + +class DB: + def __init__(self,path="example/people.db"): + self.conn = connect(path) + self.c = self.conn.cursor() + + def getList(self): + self.c.execute('SELECT * FROM people') + return self.c.fetchall() + + def close(self): + self.conn.close() + +if __name__ == "__main__": + db = DB() + print(db.getList()) + db.close() \ No newline at end of file diff --git a/Tutorial/01 SQLite in Python/sql_fill.py b/Tutorial/01 SQLite in Python/sql_fill.py new file mode 100644 index 0000000..f1787a7 --- /dev/null +++ b/Tutorial/01 SQLite in Python/sql_fill.py @@ -0,0 +1,14 @@ +import sqlite3 + +conn = sqlite3.connect('example/people.db') +c = conn.cursor() + +c.execute("DROP TABLE people") +c.execute("CREATE TABLE people (orcid CHARACTER(16), start DATE, end DATE)") +c.execute("INSERT INTO people VALUES ('0000000219094153','1900-01-01','2016-12-31')") +c.execute("INSERT INTO people VALUES ('000000020183570X','1900-01-01','2016-12-31')") +c.execute("INSERT INTO people VALUES ('0000000303977442','1900-01-01','2016-12-31')") + +conn.commit() + +conn.close()