Skip to content

Commit

Permalink
Merge pull request #287 from timrichardson/sqlite
Browse files Browse the repository at this point in the history
Sqlite URI change
  • Loading branch information
mdipierro committed Sep 8, 2015
2 parents 60e3f3e + 722bb4b commit a1125e4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
16 changes: 8 additions & 8 deletions sources/29-web2py-english/06.markmin
Expand Up @@ -42,7 +42,7 @@ web2py defines the following classes that make up the DAL:
The **DAL** object represents a database connection. For example:
``sqlite``:inxx
``
db = DAL('sqlite://storage.db')
db = DAL('sqlite://storage.sqlite')
``:code

``define_table``:inxx
Expand Down Expand Up @@ -109,7 +109,7 @@ from gluon import DAL, Field
### DAL constructor
Basic use:
``
>>> db = DAL('sqlite://storage.db')
>>> db = DAL('sqlite://storage.sqlite')
``:code

The database is now connected and the connection is stored in the global variable ``db``.
Expand All @@ -118,7 +118,7 @@ At any time you can retrieve the connection string.
``_uri``:inxx
``
>>> print db._uri
sqlite://storage.db
sqlite://storage.sqlite
``:code

and the database name
Expand Down Expand Up @@ -167,14 +167,14 @@ DAL(

A connection with the database is established by creating an instance of the DAL object:
``
>>> db = DAL('sqlite://storage.db', pool_size=0)
>>> db = DAL('sqlite://storage.sqlite', pool_size=0)
``:code
``db`` is not a keyword; it is a local variable that stores the connection object ``DAL``. You are free to give it a different name. The constructor of ``DAL`` requires a single argument, the connection string. The connection string is the only web2py code that depends on a specific back-end database. Here are examples of connection strings for specific types of supported back-end databases (in all cases, we assume the database is running from localhost on its default port and is named "test"):

``ndb``:index

-------------
**SQLite** | ``sqlite://storage.db``
**SQLite** | ``sqlite://storage.sqlite``
**MySQL** | ``mysql://username:password@localhost/test``
**PostgreSQL** | ``postgres://username:password@localhost/test``
**MSSQL (legacy)** | ``mssql://username:password@localhost/test``
Expand Down Expand Up @@ -290,7 +290,7 @@ This is a list of strings that contain the database back-end adapter names.

The adapter name is the same as used in the DAL connection string. So if you want to check against PostgreSQL and MSSQL then your connection string would look as follows:
``
db = DAL('sqlite://storage.db',
db = DAL('sqlite://storage.sqlite',
check_reserved=['postgres', 'mssql'])
``:code

Expand Down Expand Up @@ -686,7 +686,7 @@ There may not be two tables in the same application with the same migrate filena

The DAL class also takes a "migrate" argument, which determines the default value of migrate for calls to ``define_table``. For example,
``
>>> db = DAL('sqlite://storage.db', migrate=False)
>>> db = DAL('sqlite://storage.sqlite', migrate=False)
``:code

will set the default value of migrate to False whenever ``db.define_table`` is called without a migrate argument.
Expand Down Expand Up @@ -922,7 +922,7 @@ Currently the DAL API does not provide a command to create indexes on tables, bu

Here is an example of how to [[create an index using SQL in SQLite http://www.sqlite.org/lang_createindex.html]]:
``
>>> db = DAL('sqlite://storage.db')
>>> db = DAL('sqlite://storage.sqlite')
>>> db.define_table('person', Field('name'))
>>> db.executesql('CREATE INDEX IF NOT EXISTS myidx ON person (name);')
``:code
Expand Down
8 changes: 3 additions & 5 deletions sources/29-web2py-english/11.markmin
Expand Up @@ -60,7 +60,7 @@ Here is an example of how the other effects play well together.

Consider a **test** app with the following model:
``
db = DAL("sqlite://db.db")
db = DAL("sqlite://storage.sqlite")
db.define_table('child',
Field('name'),
Field('weight', 'double'),
Expand Down Expand Up @@ -260,10 +260,8 @@ As an example, create an input form that asks for a taxpayer's name and for the

Create a test application with the following model:
``
db = DAL('sqlite://db.db')
db = DAL('sqlite://storage.sqlite')
db.define_table('taxpayer',
Field('name'),
Field('married', 'boolean'),
Field('spouse_name'))
``:code

Expand Down Expand Up @@ -490,7 +488,7 @@ It contains a form "myform" and a "target" DIV. When the form is submitted, the

Build a ``test`` application with the following model:
``
db = DAL('sqlite://db.db')
db = DAL('sqlite://storage.sqlite')
db.define_table('post', Field('your_message', 'text'))
db.post.your_message.requires = IS_NOT_EMPTY()
``:code
Expand Down

0 comments on commit a1125e4

Please sign in to comment.