sqlite

SQLITE moving average

。_饼干妹妹 提交于 2020-01-17 07:36:48
问题 Trying to get the moving average on a per X months basis using SQLite. Problem is i cannot seem to figure or find anything remotely useful on how to aggregate with a X month(s) lookback period and thus create a moving average. Table CREATE TABLE "nav" ( `id` TEXT, `nav` NUMERIC, `date` TEXT ); Sample data id nav date 1380 15.3 2005-01-09 1380 15.4 2005-01-16 1380 15.5 2005-01-23 1380 15.55 2005-01-30 1380 15.66 2005-02-06 1380 15.45 2005-02-13 1380 15.26 2005-02-20 1380 15.14 2005-02-27 1380

How to query using a different field other than the PK (primary key) field in DetailView

谁都会走 提交于 2020-01-17 06:45:02
问题 url.py urlpatterns = [ url(r'^employee/(?P<emp_no>[0-9]+)/$', TitleDetail.as_view(), name='e-title'), # /employee/10001/ ] views.py class TitleDetail(DetailView): model = Title pk_url_kwarg = "emp_no" def get_context_data(self, **kwargs): context = super(TitleDetail, self).get_context_data(**kwargs) context['title_list'] = Title.objects.filter(emp_no_id=self.kwargs['emp_no']) return context models.py class Title(models.Model): emp_no = models.ForeignKey(Employee) title = models.CharField(max

Python - sqlite3 cannot select right after update-commit - works on retry

十年热恋 提交于 2020-01-17 06:05:57
问题 tst = dbConnection.execute("SELECT nameshort, namefull, timelastpostsecs, qtypostlasttime FROM " + tableToUse + " WHERE compid = ?", (str(row['compid']),)) Give following error when run 3rd time in cycle where row is different each time: sqlite3.InterfaceError: Error binding parameter 0 - probably unsupported type. Select is run right after update - commit to check update. When I copy code from error message and execute it again in IDE Python (where I run script), it works w/out error. What

Python - sqlite3 cannot select right after update-commit - works on retry

ⅰ亾dé卋堺 提交于 2020-01-17 06:05:03
问题 tst = dbConnection.execute("SELECT nameshort, namefull, timelastpostsecs, qtypostlasttime FROM " + tableToUse + " WHERE compid = ?", (str(row['compid']),)) Give following error when run 3rd time in cycle where row is different each time: sqlite3.InterfaceError: Error binding parameter 0 - probably unsupported type. Select is run right after update - commit to check update. When I copy code from error message and execute it again in IDE Python (where I run script), it works w/out error. What

how to query today in sqlite

给你一囗甜甜゛ 提交于 2020-01-17 06:04:33
问题 I have a local database in android using sqlite , i used active android and my table pojo is like this: @Column(index = true, unique = true , onUniqueConflict = Column.ConflictAction.REPLACE) public long taskId; @Column( index = true) public String taskIdno; @Column() public String taskDescription; @Column() public String taskTypeId; @Column() public String customerName; @Column() public String customerContact; @Column() public String address; @Column(index = true) public int status; @Column(

how to query today in sqlite

时光怂恿深爱的人放手 提交于 2020-01-17 06:04:29
问题 I have a local database in android using sqlite , i used active android and my table pojo is like this: @Column(index = true, unique = true , onUniqueConflict = Column.ConflictAction.REPLACE) public long taskId; @Column( index = true) public String taskIdno; @Column() public String taskDescription; @Column() public String taskTypeId; @Column() public String customerName; @Column() public String customerContact; @Column() public String address; @Column(index = true) public int status; @Column(

ionic 2 SQLite manage callback with Promise

白昼怎懂夜的黑 提交于 2020-01-17 05:53:33
问题 I want to get the callback of a successful SQLite transaction with Ionic 2. I am still currently learning the HTML5 Promise, and it is still a bit confuse. And since I've heavily used jQuery Deferred before, I try to adapt what I used to do with jQuery. Before Ionic 2, I used the following jQuery pattern to execute my async SQL: var SqlResult = function(sqlToExecute,bracketValues){ this.sqlToExecute = sqlToExecute; this.bracketValues =bracketValues; }; SqlResult.prototype

Encoding problem in sqlite and objective-c

亡梦爱人 提交于 2020-01-17 04:34:06
问题 I have a file with contents something like this: INSERT INTO table VALUES (NULL,'° F','Degrees Fahrenheit'); INSERT INTO table VALUES (NULL,'° C','Degrees Celsius'); Now, to parse this, I have something like this: NSString *sql = [NSString stringWithContentsOfFile:filename]; Printing this string to the console looks correct. Then, I want to make an actual insert statement out of it: const char *sqlString = [query UTF8String]; const char *endOfString; if (sqlite3_prepare_v2(db, sqlString +

Upgrading DB when using existing Database with Android App

核能气质少年 提交于 2020-01-17 04:31:26
问题 I am using my existing Database with my android contact app. It works fine for the first time. If I upgrade the Asset folder's Database and reinstall the app the Database doesn't upgrade it show the old one during the app run on emulator. How the onUpgrade() method works if I change the DB version on every release of app in case of using existing Database? Here is my DataBaseHelper.java import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io

How to get the closest dates in sqlite database to present date

杀马特。学长 韩版系。学妹 提交于 2020-01-17 04:25:07
问题 I have an SQLite database with a table that holds a column full of dates. I need to get the date closest to the present date out of everything in that column, but I don't know how to build a query for this. For example I have the following dates in the column 3/15/2015 3/31/2015 4/15/2015 4/30/2015 5/15/2015 5/30/2015 If the current date is 4/20/2015 I need it to get all rows that have the date. EDIT For clarification I need the only the upcoming dates not the past dates. 4/30/2015 Also my