How do I search for a certain text pattern in column data when coding in python using the sqlite3 package?
-
5You might find this question interesting.Aaron Christiansen– Aaron Christiansen2016-04-09 19:52:10 +00:00Commented Apr 9, 2016 at 19:52
-
Can you add an example of what you mean?Padraic Cunningham– Padraic Cunningham2016-04-09 20:13:44 +00:00Commented Apr 9, 2016 at 20:13
-
Do you mean that you can access MySQL with a sqllite3 module? This is new to mePullie– Pullie2016-04-09 20:24:14 +00:00Commented Apr 9, 2016 at 20:24
-
1@Pullie: Yes! .... do something like this: import sqlite3 conn = sqlite3.connect('aDB.db') c = conn.cursor() c.execute('SELECT name FROM sqlite_master WHERE type=\'table\'') #list all tables in the database print c.fetchall() c.execute('SELECT sql FROM sqlite_master WHERE type=\'table\' AND name=\'sales\'') #list columns in table 'sales' print c.fetchall() conn.close()Elle Ameli– Elle Ameli2016-04-09 20:26:42 +00:00Commented Apr 9, 2016 at 20:26
-
1Why are dates allowed to be used in different formats? It would be easier to only allow dates to be one format.ryanmoir– ryanmoir2016-04-09 21:05:09 +00:00Commented Apr 9, 2016 at 21:05
|
Show 4 more comments
1 Answer
From this question How do I use regex in a SQLite query?
SQLite3 supports the REGEXP operator:
WHERE x REGEXP <regex>