sqlite

python - sqlite InterfaceError: Error binding parameter 0 - probably unsupported type

烈酒焚心 提交于 2021-01-28 07:22:27
问题 i am using sqlite3 to store values into database, My problem is i have created lineedits through which i extract values and store it to variables and pass this variables to insert query but i am getting above error at line values(?,?,?,?,?)......if i hard quote the values directly to variables it gets saved into database what is the mistake am i doing? please help.......here is my code self.uname = self.le1.text() self.passwd = self.le2.text() self.permssn = self.le3.text() self.queryCurs

Accessing a TEMP TABLE in a TRIGGER on a VIEW

我与影子孤独终老i 提交于 2021-01-28 07:06:01
问题 I need to parameterize a view, and I am doing so by creating a TEMP TABLE which has the parameters for the view. CREATE TEMP TABLE parms (parm1 INTEGER, parm2 INTEGER); CREATE VIEW tableview AS ... The VIEW is rather complex, but it basically uses these two parameters to kick start a recursive CTE, and there isn't any other way that I have found to express the view without these parameters. The parameters must be stored in a temporary table because each connection should be able to have its

SQLITE Select results into a string

孤街醉人 提交于 2021-01-28 07:05:32
问题 I am looking for a method to return the results of an SQLite query as a single string for use in an internal trigger. Something like Python's 'somestring'.join() method. Table: foo id | name 1 | "foo" 2 | "bar" 3 | "bro" Then a select statement: MAGIC_STRING_CONCAT_FUNCTION(SELECT id FROM foo,","); To return "1,2,3" 回答1: You're looking for the group_concat function: group_concat((SELECT id FROM foo), ","); The following is the description of the function group_concat from the documentation:

Jest test are run before DB is ready

二次信任 提交于 2021-01-28 06:52:16
问题 I am using Jest to test my express API with SQLite database, but the following problem appeared - test are run before DB is ready and tables are created. I connect to DB with following code: const connectToDatabase = () => { let db; if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'production') { db = new sqlite3.Database('task_list'); } else if (process.env.NODE_ENV === 'test') { db = new sqlite3.Database(':memory:'); } else { throw new Error('Environment is not defined

Can you use MySQL to connect to a standalone database e.g. “mydata.db”?

荒凉一梦 提交于 2021-01-28 06:50:29
问题 Pretty sure the answer is "no" but I have found no conclusive result... Basically, can use MySQL to connect to a standalone database file and then use standard MySQL commands on it? Currently I use SQLite3 to do exactly this but I now like the usage of MySQL commands whilst retaining the single file devoid of a MySQL server. Is it possible? Ilmiont 回答1: Not possible with mysql function, but still possible with PDO . Most SQL Commands should work in any SQL Based RDBMS. PDO is meant to have a

Store & retrieve array in SQLite database in Xamarin

懵懂的女人 提交于 2021-01-28 06:20:25
问题 I wanted to store and retrieve an array in a SQLite database in my Xamarin App. I'm following this Xamarin Tutorial on SQLite. These values will be then show in Picker . I used Models earlier to store array and then get the values and list it in Picker , it was working fine, but the only problem was that it wasn't stored permanently (by closing app array list get empty). Banks using SQLite; namespace Mobile.App { public class Banks { [PrimaryKey, AutoIncrement] public int ID { get; set; }

Sqlite GROUP BY priority

大兔子大兔子 提交于 2021-01-28 05:29:07
问题 +----+------------+------+ | id | title | lang | +----+------------+------+ | 1 | title 1 EN | en | | 1 | title 1 FR | fr | | 1 | title 1 ZH | zh | | 2 | title 2 EN | en | | 3 | title 3 ZH | zh | +----+------------+------+ this is my table and I want to group by id but I sometimes I need language "en" to have priority and sometimes I need to have language "zh" as priority SELECT * FROM table GROUP BY id gives me a list of all uniqe ids but places zh in favor for id 1, is it possible that I

getContentResolver().query android where clause

余生颓废 提交于 2021-01-28 05:28:01
问题 My query is regarding the creation of the function parameters for getting data from the database. I want the cursor to returns only specific rows instead of complete recordset. c= getContentResolver().query(uri, null, "column1=? \"mysearch\" or column2=? "\mysearch"\", null, "date DESC"); I want to get the results where column1 like "mysearch" or column2 like "mysearch" . In the above example i have tried with some hardcoded values. Regards, Nirav 回答1: Got it after some workaround. The

Python - How to connect SQLAlchemy to existing database in memory

徘徊边缘 提交于 2021-01-28 04:40:19
问题 I'm creating my DB from an existing shema and it's stored in :memory: . db = Database(filename=':memory:', schema='schema.sql') db.recreate() I now want to "link" this to SQL Alchemy. Followed different methods but could not get it right. My current attempt stands as follow: engine = create_engine('sqlite:///:memory:') Base = automap_base() Base.prepare(engine, reflect=True) User = Base.classes.user session = Session(engine) Much like the other stuff I tried this will throw AttributeError:

Python - How to connect SQLAlchemy to existing database in memory

浪子不回头ぞ 提交于 2021-01-28 04:31:00
问题 I'm creating my DB from an existing shema and it's stored in :memory: . db = Database(filename=':memory:', schema='schema.sql') db.recreate() I now want to "link" this to SQL Alchemy. Followed different methods but could not get it right. My current attempt stands as follow: engine = create_engine('sqlite:///:memory:') Base = automap_base() Base.prepare(engine, reflect=True) User = Base.classes.user session = Session(engine) Much like the other stuff I tried this will throw AttributeError: