KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am trying to create a function in Python 2.7.3 to open a SQLite database. This is my code at the moment: import sqlite3 as lite import sys db = r'someDb.sqlite' def opendb(db): try: conn = lite.connect(db) except sqlite3.Error: print "Error open db.\n" return False cur = conn.cursor() return [conn, cur] I have tried the code above and I have observed that the sqlite3 library opens the database declared if exists, or creates a new database if this one doesn't exist. Is there a way to check if the database exists with sqlite3 methods or I have to use file operation like os.path.isfile(path) ?
Tags (comma-separated)
Save Edits
Cancel