Skip to content
This repository

SQLite doesn't recognize data type "string" #655

Merged
merged 1 commit into from over 1 year ago

2 participants

Oliver Song Armin Ronacher
Oliver Song

If you submit a field with an integer and commit to DB as a string, SQLite will cast it to an integer, which can cause problems.

I was making something based on the Flask tutorial and I couldn't figure out why my data was coming back as type "int" when I had inserted to the DB as "string".

The field needs to be something that has text-affinity in SQLite, so I changed it to type "text".

Hope this helps?

Armin Ronacher mitsuhiko merged commit ab3d9d1 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Dec 26, 2012
Oliver Song oliversong Changing string to text in schema files cc82feb
This page is out of date. Refresh to see the latest.
4 docs/tutorial/schema.rst
Source Rendered
@@ -13,8 +13,8 @@ the just created `flaskr` folder:
13 13 drop table if exists entries;
14 14 create table entries (
15 15 id integer primary key autoincrement,
16   - title string not null,
17   - text string not null
  16 + title text not null,
  17 + text text not null
18 18 );
19 19
20 20 This schema consists of a single table called `entries` and each row in
4 examples/flaskr/schema.sql
... ... @@ -1,6 +1,6 @@
1 1 drop table if exists entries;
2 2 create table entries (
3 3 id integer primary key autoincrement,
4   - title string not null,
5   - text string not null
  4 + title text not null,
  5 + text text not null
6 6 );
8 examples/minitwit/schema.sql
... ... @@ -1,9 +1,9 @@
1 1 drop table if exists user;
2 2 create table user (
3 3 user_id integer primary key autoincrement,
4   - username string not null,
5   - email string not null,
6   - pw_hash string not null
  4 + username text not null,
  5 + email text not null,
  6 + pw_hash text not null
7 7 );
8 8
9 9 drop table if exists follower;
@@ -16,6 +16,6 @@ drop table if exists message;
16 16 create table message (
17 17 message_id integer primary key autoincrement,
18 18 author_id integer not null,
19   - text string not null,
  19 + text text not null,
20 20 pub_date integer
21 21 );

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.