url
(str) - URL that specifies the database to connect to.
Some examples:
-
Opening an SQLite file:
dao =
CrashDAO("sqlite:///C:\some\path\database.sqlite")
-
Connecting to a locally installed SQL Express database:
dao =
CrashDAO("mssql://.\SQLEXPRESS/Crashes?trusted_connection=yes")
-
Connecting to a MySQL database running locally, using the
oursql
library, authenticating as the
"winappdbg" user with no password: dao =
CrashDAO("mysql+oursql://winappdbg@localhost/Crashes")
-
Connecting to a Postgres database running locally,
authenticating with user and password:
dao =
CrashDAO("postgresql://winappdbg:winappdbg@localhost/Crashes")
For more information see the SQLAlchemy
documentation online: http://docs.sqlalchemy.org/en/latest/core/engines.html
Note that in all dialects except for SQLite the database must
already exist. The tables schema, however, is created
automatically when connecting for the first time.
To create the database in MSSQL, you can use the SQLCMD command:
sqlcmd -Q "CREATE DATABASE Crashes"
In MySQL you can use something like the following:
mysql -u root -e "CREATE DATABASE Crashes;"
And in Postgres:
createdb Crashes -h localhost -U winappdbg -p winappdbg -O winappdbg
Some small changes to the schema may be tolerated (for
example, increasing the maximum length of string columns, or
adding new columns with default values). Of course, it's best to
test it first before making changes in a live database. This all
depends very much on the SQLAlchemy version you're using, but
it's best to use the latest version always.