Commit 2d80b69a authored by Mathieu Loiseau's avatar Mathieu Loiseau
Browse files

DB connection

parent f7a33e43
......@@ -2,8 +2,9 @@
# -*- coding: UTF-8 -*-
# created by lzbk
import argparse
import os ,sys
import os, sys, os.path
import getpass
import sqlite3
parser = argparse.ArgumentParser(description="Extraire les notes d'une liseuse Vivlio")
parser.add_argument("-s", "--source", help="le dossier de la liseuse", type=str, default=None)
......@@ -29,11 +30,26 @@ def getSource():
res=None
return res
def connect(sourceDir):
try:
path = sourceDir+'/system/config/books.db'
if not os.path.isfile(path):
raise ValueError ("Failed to connect to DB ("+path+").")
else:
conn = sqlite3.connect(path)
print("Connected to '"+path+"'.")
except (ValueError,sqlite3.Error) as e:
print (str(e))
conn = None
return conn
#main
if __name__ == "__main__":
if args.source == None:
source = getSource()
print(source)
else:
source = args.source
if source != None:
conn = connect(source)
if conn != None:
conn.close()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment