Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- #
- # Source: SQLite Python: Creating a New Database
- # https://www.sqlitetutorial.net/sqlite-python/creating-database/
- #
- import sqlite3
- from sqlite3 import Error
- def create_connection(db_file):
- """ create a database connection to a SQLite database """
- con = None
- try:
- if db_file != "":
- # use a file based database
- conn = sqlite3.connect(db_file)
- else:
- # use a in-memory database
- conn = sqlite3.connect(':memory:')
- print(sqlite3.version)
- except Error as e:
- print(e)
- finally:
- if conn:
- conn.close()
- if __name__ == '__main__':
- #create_connection("./pythonsqlite.db")
- create_connection("")
Advertisement
Add Comment
Please, Sign In to add comment