Python sqlite3 parameterized drop table

You cannot use parameters for table names nor column names. Alternatively you could make it a two-step process, e.g.: a_table_name = “table_a” sql_stmt = f”””DROP TABLE {a_table_name}””” self.conn.execute(sql_stmt) And if you’re doing that you may want to explicitly specify which tables can be deleted… TABLES_THAT_CAN_BE_DROPPED = (‘table_a’,’table_b’,) if a_table_name in TABLES_THAT_CAN_BE_DROPPED: # use code snippet … Read more

DbFunctions.TruncateTime LINQ equivalent in EF CORE

In EF6 DbFunctions.TruncateTime is used instead of DateTime.Date property because for some reason the later is not supported. In EF Core the former is not needed simply because DateTime.Date now is recognized and translated correctly. group events by events.DateTimeFrom.Date into dateGroup Unfortunately there is no documentation (yet) of what is supported, so as a general … Read more

Passing SQLite variables in Python

Use parameters to .execute(): query = “”” INSERT INTO credit (bank, number, card, int1, value, type, int2) VALUES (?, ?, ?, ?, ?, ?, ?) “”” data = [‘Citi’, ‘5567’, ‘visa’, 6000, 9.99, ’23’, 9000] cursor.execute(query, data) According to PEP249: .execute(operation[,parameters]): Prepare and execute a database operation (query or command). Parameters may be provided as … Read more

Creating stored procedure in SQLite

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