MCPcopy Create free account
hub / github.com/erans/pgsqlite / get_sqlite_columns

Method get_sqlite_columns

src/schema_drift.rs:195–216  ·  view source on GitHub ↗
(conn: &Connection, table_name: &str)

Source from the content-addressed store, hash-verified

193 }
194
195 fn get_sqlite_columns(conn: &Connection, table_name: &str) -> Result<HashMap<String, ColumnInfo>, rusqlite::Error> {
196 let query = format!("PRAGMA table_info({table_name})");
197 let mut stmt = conn.prepare(&query)?;
198
199 let mut columns = HashMap::new();
200 let rows = stmt.query_map([], |row| {
201 Ok(ColumnInfo {
202 name: row.get(1)?,
203 pg_type: String::new(), // Not available from PRAGMA
204 sqlite_type: row.get(2)?,
205 nullable: row.get::<_, i32>(3)? == 0,
206 default_value: row.get(4)?,
207 })
208 })?;
209
210 for row in rows {
211 let col = row?;
212 columns.insert(col.name.clone(), col);
213 }
214
215 Ok(columns)
216 }
217
218 fn normalize_sqlite_type(type_str: &str) -> String {
219 let upper = type_str.to_uppercase();

Callers

nothing calls this directly

Calls 3

getMethod · 0.45
insertMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected