sqlite database default time value ‘now’
i believe you can use CREATE TABLE test ( id INTEGER PRIMARY KEY AUTOINCREMENT, t TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); as of version 3.1 (source)
i believe you can use CREATE TABLE test ( id INTEGER PRIMARY KEY AUTOINCREMENT, t TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); as of version 3.1 (source)
If you never want to have duplicates, you should declare this as a table constraint: CREATE TABLE bookmarks( users_id INTEGER, lessoninfo_id INTEGER, UNIQUE(users_id, lessoninfo_id) ); (A primary key over both columns would have the same effect.) It is then possible to tell the database that you want to silently ignore records that would violate such … Read more
You could use cursor.lastrowid (see “Optional DB API Extensions”): connection=sqlite3.connect(‘:memory:’) cursor=connection.cursor() cursor.execute(”’CREATE TABLE foo (id integer primary key autoincrement , username varchar(50), password varchar(50))”’) cursor.execute(‘INSERT INTO foo (username,password) VALUES (?,?)’, (‘test’,’test’)) print(cursor.lastrowid) # 1 If two people are inserting at the same time, as long as they are using different cursors, cursor.lastrowid will return the … Read more
SQLite has had to sacrifice other characteristics that some people find useful, such as high concurrency, fine-grained access control, a rich set of built-in functions, stored procedures, esoteric SQL language features, XML and/or Java extensions, tera- or peta-byte scalability, and so forth Source : Appropriate Uses For SQLite
If most of those concurrent accesses are reads (e.g. SELECT), SQLite can handle them very well. But if you start writing concurrently, lock contention could become an issue. A lot would then depend on how fast your filesystem is, since the SQLite engine itself is extremely fast and has many clever optimizations to minimize contention. … Read more
The || operator is “concatenate” – it joins together the two strings of its operands. From http://www.sqlite.org/lang_expr.html For padding, the seemingly-cheater way I’ve used is to start with your target string, say ‘0000’, concatenate ‘0000423’, then substr(result, -4, 4) for ‘0423’. Update: Looks like there is no native implementation of “lpad” or “rpad” in SQLite, … Read more
The best way is to store the dates as a number, received by using the Calendar command. //Building the table includes: StringBuilder query=new StringBuilder(); query.append(“CREATE TABLE “+TABLE_NAME+ ” (“); query.append(COLUMN_ID+”int primary key autoincrement,”); query.append(COLUMN_DATETIME+” int)”); //And inserting the data includes this: values.put(COLUMN_DATETIME, System.currentTimeMillis()); Why do this? First of all, getting values from a date range … Read more
Pretty much down to personal choice. It may make sense to use an extension based on the database scheme you are storing; treat your database schema as a file format, with SQLite simply being an encoding used for that file format. So, you might use .bookmarks if it’s storing bookmarks, or .index if it’s being … Read more
I know I’m late to the party but I had this issue right after I pulled down latest x86/x64 today (version 1.0.88.0). My local IIS in VS2012 runs 32bit by default and there’s no easy way to switch to x64. My production server runs 64bit. Anyway I installed the NuGet package to a DLL project … Read more
Everyone seems to starts off with a few greps and perl expressions and you sorta kinda get something that works for your particular dataset but you have no idea if it’s imported the data correctly or not. I’m seriously surprised nobody’s built a solid library that can convert between the two. Here a list of … Read more