sqliteHow can I use SQLite in a portable way?
SQLite is an open-source, zero-configuration, serverless, transactional SQL database engine that is perfect for use in a portable way. It is a self-contained, embedded, full-featured, public-domain, SQL database engine.
To use SQLite in a portable way, you can create a database file in the same directory as your program and access it using the sqlite3 module. For example, the following code creates a database file called "mydb.db" and creates a table called "persons" with two columns:
import sqlite3
conn = sqlite3.connect('mydb.db')
c = conn.cursor()
# Create table
c.execute('''CREATE TABLE persons
(id int, name text)''')
# 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()
This code will create an empty database file called mydb.db in the same directory as the program. You can then use the sqlite3 module to perform any database operations on the database file.
For more information, see the SQLite documentation and the sqlite3 module documentation.
More of Sqlite
- How can SQLite and ZFS be used together for software development?
- How do I call sqlitepcl.raw.setprovider() when using SQLite?
- How do I use the SQLite ZIP VFS to compress a database?
- How can I use SQLite with Zabbix?
- How do I import data from a SQLite zip file?
- How can I use SQLite to query for records between two specific dates?
- How do I set up an ODBC driver to connect to an SQLite database?
- How can I use the XOR operator in a SQLite query?
- How do I use UUIDs in SQLite?
- How do I use variables in a SQLite database?
See more codes...